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 {
4747 this . _zoneProc = new Map ( [
4848 [
4949 Prop . toplevel_category , {
50+ /* Token handlers for Marked >= v1.0.0 */
51+ 'list' : list => {
52+ for ( const item of list . get ( '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 */
5076 'list_item_start' : ( ) => {
5177 this . _single_bufs . push ( '' )
5278 } ,
@@ -67,8 +93,8 @@ class ArticleProcessor {
6793 )
6894 } ,
6995 '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 ( )
7298 } ,
7399 }
74100 ] ,
You can’t perform that action at this time.
0 commit comments