// Generated by CoffeeScript 1.7.1
var cheerio;

cheerio = require('cheerio');

module.exports = function(content) {
  var $, child, item, listItems, list_iterator, render_item_checkbox, _i, _len;
  $ = cheerio.load(content);
  render_item_checkbox = function(html, checked) {
    var label;
    label = html.slice(3, +(html.length - 1) + 1 || 9e9);
    return "<label>\n  <input type=\"checkbox\"\n  class=\"task-list-item-checkbox\"\n  " + checked + "/>\n  " + label + "\n</label>";
  };
  list_iterator = function(item) {
    var detached, srcHtml;
    srcHtml = $(item).clone().children().remove('il, ul').end().html();
    detached = $(item).children('il, ul');
    if (/^\[x\]/.test(srcHtml)) {
      return $(item).html(render_item_checkbox(srcHtml, "checked")).append(detached);
    } else if (/^\[ \]/.test(srcHtml)) {
      return $(item).html(render_item_checkbox(srcHtml, "")).append(detached);
    }
  };
  listItems = $('li');
  for (_i = 0, _len = listItems.length; _i < _len; _i += 1) {
    item = listItems[_i];
    child = $(item).children().first()['0'];
    list_iterator(item);
    if (child) {
      if (child.name === "p") {
        list_iterator(child);
      }
    }
  }
  return $.html();
};
