Skip to content

Commit 9bf262c

Browse files
author
Sethen
committed
Changed markdown.json options, added heading option for table of contents
1 parent 28c6d9a commit 9bf262c

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
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

docs/how_to_use.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff 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) |

markdown-include.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@
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);

markdown.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"build" : "README.md",
33
"files" : ["./docs/_README.md"],
4-
"tableOfContents": true
4+
"tableOfContents": {
5+
"heading": "# Table of Contents"
6+
}
57
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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": {

0 commit comments

Comments
 (0)