File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,32 @@ class ArticleProcessor {
47
47
this . _zoneProc = new Map ( [
48
48
[
49
49
Prop . toplevel_category , {
50
+ /* Token handlers for Marked >= v1.0.0 */
51
+ 'list' : list => {
52
+ for ( const item of list . items ) {
53
+ if ( item . type != 'list_item' ) continue
54
+
55
+ let buf = ''
56
+ for ( const token of item . tokens ) {
57
+ if ( token . type == 'text' )
58
+ buf += token . text
59
+ }
60
+
61
+ const m = buf . match ( / ^ ( [ ^ [ ] + ) \[ ( [ ^ \] ] + ) \] $ / )
62
+ if ( ! m ) {
63
+ throw new Error ( `[BUG] unhandled format ${ buf } ` )
64
+ }
65
+
66
+ this . _categories . set (
67
+ m [ 2 ] ,
68
+ new Priority (
69
+ this . _currentIndex ++ , m [ 1 ]
70
+ )
71
+ )
72
+ }
73
+ } ,
74
+
75
+ /* Token handlers for Marked < v1.0.0 */
50
76
'list_item_start' : ( ) => {
51
77
this . _single_bufs . push ( '' )
52
78
} ,
@@ -67,8 +93,8 @@ class ArticleProcessor {
67
93
)
68
94
} ,
69
95
'text' : token => {
70
- // console.log(token )
71
- this . _single_bufs [ this . _single_bufs . length - 1 ] += token . get ( 'text' ) . trim ( )
96
+ if ( this . _single_bufs . length > 0 )
97
+ this . _single_bufs [ this . _single_bufs . length - 1 ] += token . get ( 'text' ) . trim ( )
72
98
} ,
73
99
}
74
100
] ,
You can’t perform that action at this time.
0 commit comments