File tree Expand file tree Collapse file tree 5 files changed +25
-15
lines changed
Expand file tree Collapse file tree 5 files changed +25
-15
lines changed Original file line number Diff line number Diff line change 1+ # Table of Contents
2+
13* [ markdown-include] ( #markdown-include )
24 * [ Compile your markdown files] ( #compile-your-markdown-files )
35 * [ Make a table of contents] ( #make-a-table-of-contents )
@@ -69,12 +71,12 @@ node path/to/markdown-include.js path/to/markdown.json
6971
7072` markdown.json ` can be populated with the following options:
7173
72- | Option | Type | Description |
73- | :-----------------:| :-------------:| :--------------------------------------------------------------------------:|
74- | ` build ` | String | File path of where everything should be compiled, like ` README.md ` |
75- | ` files ` | Array | Array of files to to compile |
76- | ` tableOfContents ` | Boolean | ` true ` to build table of contents dynamically |
77-
74+ | Option | Type | Description |
75+ | :------------------------- :| :-------------:| :--------------------------------------------------------------------------:|
76+ | ` build ` | String | File path of where everything should be compiled, like ` README.md ` |
77+ | ` files ` | Array | Array of files to to compile |
78+ | ` tableOfContents ` | Object | Object to hold options for table of contents generation |
79+ | ` tableOfContents.heading ` | String | Heading for table of contents, added to the ` tableOfContents ` object |
7880
7981# How It Works
8082
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ node path/to/markdown-include.js path/to/markdown.json
1010
1111` markdown.json ` can be populated with the following options:
1212
13- | Option | Type | Description |
14- | :-----------------:| :-------------:| :--------------------------------------------------------------------------:|
15- | ` build ` | String | File path of where everything should be compiled, like ` README.md ` |
16- | ` files ` | Array | Array of files to to compile |
17- | ` tableOfContents ` | Boolean | ` true ` to build table of contents dynamically |
18-
13+ | Option | Type | Description |
14+ | :------------------------- :| :-------------:| :--------------------------------------------------------------------------:|
15+ | ` build ` | String | File path of where everything should be compiled, like ` README.md ` |
16+ | ` files ` | Array | Array of files to to compile |
17+ | ` tableOfContents ` | Object | Object to hold options for table of contents generation |
18+ | ` tableOfContents.heading ` | String | Heading for table of contents (use markdown syntax if desired) |
Original file line number Diff line number Diff line change 109109
110110 if ( options . tableOfContents ) {
111111 compileHeadingTags ( file ) ;
112- build [ file ] . parsedData = tableOfContents + '\n\n' + build [ file ] . parsedData ;
112+
113+ if ( options . tableOfContents . heading ) {
114+ build [ file ] . parsedData = options . tableOfContents . heading + '\n\n' + tableOfContents + '\n\n' + build [ file ] . parsedData ;
115+ }
116+ else {
117+ build [ file ] . parsedData = tableOfContents + '\n\n' + build [ file ] . parsedData ;
118+ }
113119 }
114120
115121 writeFile ( options , build [ file ] . parsedData ) ;
Original file line number Diff line number Diff line change 11{
22 "build" : " README.md" ,
33 "files" : [" ./docs/_README.md" ],
4- "tableOfContents" : true
4+ "tableOfContents" : {
5+ "heading" : " # Table of Contents"
6+ }
57}
Original file line number Diff line number Diff line change 11{
22 "name" : " markdown-include" ,
3- "version" : " 0.2.1 " ,
3+ "version" : " 0.2.2 " ,
44 "description" : " Include markdown files into other markdown files with C style syntax." ,
55 "main" : " markdown-include.js" ,
66 "repository" : {
You can’t perform that action at this time.
0 commit comments