File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -94,18 +94,35 @@ function parseChapter(nodes, nums) {
9494 } ) ;
9595}
9696
97+ function defaultChapterList ( chapterList ) {
98+ var first = _ . first ( chapterList ) ;
99+
100+ var chapter = parseChapter ( first , [ 0 ] ) ;
101+
102+ // Already have README node, we're good to go
103+ if ( chapter . path === 'README.md' ) {
104+ return chapterList ;
105+ }
106+
107+ return [
108+ [ { type : 'text' , text : '[Introduction](README.md)' } ]
109+ ] . concat ( chapterList ) ;
110+ }
111+
97112function parseSummary ( src ) {
98113 var nodes = marked . lexer ( src ) ;
99114
100115 // Get out list of chapters
101- var chapterList = filterList ( nodes ) ;
116+ var chapterList = listSplit (
117+ filterList ( nodes ) ,
118+ 'list_item_start' , 'list_item_end'
119+ ) ;
102120
103121 // Split out chapter sections
104- var chapters = _ . chain ( listSplit ( chapterList , 'list_item_start' , 'list_item_end' ) )
122+ var chapters = defaultChapterList ( chapterList )
105123 . map ( function ( nodes , i ) {
106- return parseChapter ( nodes , [ i + 1 ] ) ;
107- } )
108- . value ( ) ;
124+ return parseChapter ( nodes , [ i ] ) ;
125+ } ) ;
109126
110127 return {
111128 chapters : chapters
You can’t perform that action at this time.
0 commit comments