parent
26cef98d72
commit
a5e39a6a59
@ -378,7 +378,7 @@ Lexer.prototype.token = function(src, top, bq) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// task (gfm)
|
// task (gfm)
|
||||||
if (top && (cap = this.rules.task.exec(src)) {
|
if (top && (cap = this.rules.task.exec(src))) {
|
||||||
src = src.substring(cap[0].length);
|
src = src.substring(cap[0].length);
|
||||||
|
|
||||||
this.tokens.push({
|
this.tokens.push({
|
||||||
@ -806,6 +806,21 @@ Renderer.prototype.code = function(code, lang, escaped) {
|
|||||||
+ '\n</code></pre>\n';
|
+ '\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) {
|
Renderer.prototype.blockquote = function(quote) {
|
||||||
return '<blockquote>\n' + quote + '</blockquote>\n';
|
return '<blockquote>\n' + quote + '</blockquote>\n';
|
||||||
};
|
};
|
||||||
@ -1014,19 +1029,14 @@ Parser.prototype.tok = function() {
|
|||||||
, i = 1;
|
, i = 1;
|
||||||
|
|
||||||
while (this.next().type !== 'task_list_end') {
|
while (this.next().type !== 'task_list_end') {
|
||||||
body += '<li class="task-list-item"><label>'
|
body += this.renderer.taskitem(
|
||||||
+ '<input type="checkbox"'
|
this.inline.output(this.token.text),
|
||||||
+ ' class="task-list-item-checkbox"
|
this.token.checked,
|
||||||
+ ' data-item-index="' + (i++) + '"'
|
this.token.disabled,
|
||||||
+ ' data-item-complete="' + (this.token.checked ? 1 : 0) + '"'
|
i++);
|
||||||
+ ' ' + (this.token.disabled ? 'disabled=""' + '') + '>'
|
|
||||||
+ ' ' + this.inline.output(this.token.text)
|
|
||||||
+ '</label></li>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<ul class="task-list">'
|
return this.renderer.tasklist(body);
|
||||||
+ body
|
|
||||||
+ '</ul>';
|
|
||||||
}
|
}
|
||||||
case 'table': {
|
case 'table': {
|
||||||
var header = ''
|
var header = ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user