Skip to content

Commit

Permalink
Revert "use renderer for task lists. see #107 #111."
Browse files Browse the repository at this point in the history
This reverts commit a5e39a6.
  • Loading branch information
chjj committed Mar 10, 2014
1 parent a5e39a6 commit b5b4683
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Lexer.prototype.token = function(src, top, bq) {
}

// task (gfm)
if (top && (cap = this.rules.task.exec(src))) {
if (top && (cap = this.rules.task.exec(src)) {
src = src.substring(cap[0].length);

this.tokens.push({
Expand Down Expand Up @@ -806,21 +806,6 @@ Renderer.prototype.code = function(code, lang, escaped) {
+ '\n</code></pre>\n';
};

Renderer.prototype.tasklist = function(text) {
return '<ul class="task-list">\n' + text + '</ul>\n';
};

Renderer.prototype.taskitem = function(text, checked, disabled, i) {
return '<li class="task-list-item"><label>'
+ '<input type="checkbox"'
+ ' class="task-list-item-checkbox"'
+ ' data-item-index="' + i + '"'
+ ' data-item-complete="' + (checked ? 1 : 0) + '"'
+ (disabled ? ' disabled=""' : '') + '>'
+ ' ' + text
+ '</label></li>';
};

Renderer.prototype.blockquote = function(quote) {
return '<blockquote>\n' + quote + '</blockquote>\n';
};
Expand Down Expand Up @@ -1029,14 +1014,19 @@ Parser.prototype.tok = function() {
, i = 1;

while (this.next().type !== 'task_list_end') {
body += this.renderer.taskitem(
this.inline.output(this.token.text),
this.token.checked,
this.token.disabled,
i++);
body += '<li class="task-list-item"><label>'
+ '<input type="checkbox"'
+ ' class="task-list-item-checkbox"
+ ' data-item-index="' + (i++) + '"'
+ ' data-item-complete="' + (this.token.checked ? 1 : 0) + '"'
+ ' ' + (this.token.disabled ? 'disabled=""' + '') + '>'
+ ' ' + this.inline.output(this.token.text)
+ '</label></li>';
}

return this.renderer.tasklist(body);
return '<ul class="task-list">'
+ body
+ '</ul>';
}
case 'table': {
var header = ''
Expand Down

0 comments on commit b5b4683

Please sign in to comment.