Revert "rough implementation of task lists. see #107 #111."

This reverts commit 26cef98d7261cb8330c07eceff250254124f20d8.
This commit is contained in:
Christopher Jeffrey 2014-03-10 00:59:32 -05:00
parent b5b4683179
commit ea37585b9a

View File

@ -22,7 +22,6 @@ var block = {
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
task: noop,
table: noop,
paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
text: /^[^\n]+/
@ -76,7 +75,6 @@ block.normal = merge({}, block);
*/
block.gfm = merge({}, block.normal, {
task: /^(\s*\[[x ]\][^\n]+\n)+\n*/,
fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
paragraph: /^/
});
@ -377,33 +375,6 @@ Lexer.prototype.token = function(src, top, bq) {
continue;
}
// task (gfm)
if (top && (cap = this.rules.task.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'task_list_start'
});
cap[0] = cap[0].replace(/^\s+|\s+$/g, '');
cap = cap[0].split(/\n+/);
i = 0;
l = cap.length;
for (; i < l; i++) {
this.tokens.push({
type: 'task_item',
checked: /^\s*\[x\]/.test(cap[i]),
text: cap[i].replace(/^\s*\[[x ]\]\s*/, '')
});
}
this.tokens.push({
type: 'task_list_end'
});
}
// table (gfm)
if (top && (cap = this.rules.table.exec(src))) {
src = src.substring(cap[0].length);
@ -1009,25 +980,6 @@ Parser.prototype.tok = function() {
this.token.lang,
this.token.escaped);
}
case 'task_list_start': {
var body = ''
, i = 1;
while (this.next().type !== 'task_list_end') {
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 '<ul class="task-list">'
+ body
+ '</ul>';
}
case 'table': {
var header = ''
, body = ''