@@ -378,7 +378,7 @@ Lexer.prototype.token = function(src, top, bq) {
378
378
}
379
379
380
380
// task (gfm)
381
- if ( top && ( cap = this . rules . task . exec ( src ) ) {
381
+ if ( top && ( cap = this . rules . task . exec ( src ) ) ) {
382
382
src = src . substring ( cap [ 0 ] . length ) ;
383
383
384
384
this . tokens . push ( {
@@ -806,6 +806,21 @@ Renderer.prototype.code = function(code, lang, escaped) {
806
806
+ '\n</code></pre>\n' ;
807
807
} ;
808
808
809
+ Renderer . prototype . tasklist = function ( text ) {
810
+ return '<ul class="task-list">\n' + text + '</ul>\n' ;
811
+ } ;
812
+
813
+ Renderer . prototype . taskitem = function ( text , checked , disabled , i ) {
814
+ return '<li class="task-list-item"><label>'
815
+ + '<input type="checkbox"'
816
+ + ' class="task-list-item-checkbox"'
817
+ + ' data-item-index="' + i + '"'
818
+ + ' data-item-complete="' + ( checked ? 1 : 0 ) + '"'
819
+ + ( disabled ? ' disabled=""' : '' ) + '>'
820
+ + ' ' + text
821
+ + '</label></li>' ;
822
+ } ;
823
+
809
824
Renderer . prototype . blockquote = function ( quote ) {
810
825
return '<blockquote>\n' + quote + '</blockquote>\n' ;
811
826
} ;
@@ -1014,19 +1029,14 @@ Parser.prototype.tok = function() {
1014
1029
, i = 1 ;
1015
1030
1016
1031
while ( this . next ( ) . type !== 'task_list_end' ) {
1017
- body += '<li class="task-list-item"><label>'
1018
- + '<input type="checkbox"'
1019
- + ' class="task-list-item-checkbox"
1020
- + ' data-item-index="' + ( i ++ ) + '"'
1021
- + ' data-item-complete="' + ( this . token . checked ? 1 : 0 ) + '"'
1022
- + ' ' + ( this . token . disabled ? 'disabled=""' + '' ) + '>'
1023
- + ' ' + this . inline . output ( this . token . text )
1024
- + '</label></li>' ;
1032
+ body += this . renderer . taskitem (
1033
+ this . inline . output ( this . token . text ) ,
1034
+ this . token . checked ,
1035
+ this . token . disabled ,
1036
+ i ++ ) ;
1025
1037
}
1026
1038
1027
- return '<ul class="task-list">'
1028
- + body
1029
- + '</ul>' ;
1039
+ return this . renderer . tasklist ( body ) ;
1030
1040
}
1031
1041
case 'table' : {
1032
1042
var header = ''
0 commit comments