Skip to content

Commit

Permalink
Changed markdown.json options, added heading option for table of cont…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
Sethen committed Mar 6, 2015
1 parent 28c6d9a commit 9bf262c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Table of Contents

* [markdown-include](#markdown-include)
* [Compile your markdown files](#compile-your-markdown-files)
* [Make a table of contents](#make-a-table-of-contents)
Expand Down Expand Up @@ -69,12 +71,12 @@ node path/to/markdown-include.js path/to/markdown.json

`markdown.json` can be populated with the following options:

| Option | Type | Description |
|:-----------------:|:-------------:|:--------------------------------------------------------------------------:|
| `build` | String | File path of where everything should be compiled, like `README.md` |
| `files` | Array | Array of files to to compile |
| `tableOfContents` | Boolean | `true` to build table of contents dynamically |

| Option | Type | Description |
|:-------------------------:|:-------------:|:--------------------------------------------------------------------------:|
| `build` | String | File path of where everything should be compiled, like `README.md` |
| `files` | Array | Array of files to to compile |
| `tableOfContents` | Object | Object to hold options for table of contents generation |
| `tableOfContents.heading` | String | Heading for table of contents, added to the `tableOfContents` object |

# How It Works

Expand Down
12 changes: 6 additions & 6 deletions docs/how_to_use.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ node path/to/markdown-include.js path/to/markdown.json

`markdown.json` can be populated with the following options:

| Option | Type | Description |
|:-----------------:|:-------------:|:--------------------------------------------------------------------------:|
| `build` | String | File path of where everything should be compiled, like `README.md` |
| `files` | Array | Array of files to to compile |
| `tableOfContents` | Boolean | `true` to build table of contents dynamically |

| Option | Type | Description |
|:-------------------------:|:-------------:|:--------------------------------------------------------------------------:|
| `build` | String | File path of where everything should be compiled, like `README.md` |
| `files` | Array | Array of files to to compile |
| `tableOfContents` | Object | Object to hold options for table of contents generation |
| `tableOfContents.heading` | String | Heading for table of contents (use markdown syntax if desired) |
8 changes: 7 additions & 1 deletion markdown-include.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@

if (options.tableOfContents) {
compileHeadingTags(file);
build[file].parsedData = tableOfContents + '\n\n' + build[file].parsedData;

if (options.tableOfContents.heading) {
build[file].parsedData = options.tableOfContents.heading + '\n\n' + tableOfContents + '\n\n' + build[file].parsedData;
}
else {
build[file].parsedData = tableOfContents + '\n\n' + build[file].parsedData;
}
}

writeFile(options, build[file].parsedData);
Expand Down
4 changes: 3 additions & 1 deletion markdown.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"build" : "README.md",
"files" : ["./docs/_README.md"],
"tableOfContents": true
"tableOfContents": {
"heading": "# Table of Contents"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-include",
"version": "0.2.1",
"version": "0.2.2",
"description": "Include markdown files into other markdown files with C style syntax.",
"main": "markdown-include.js",
"repository": {
Expand Down

0 comments on commit 9bf262c

Please sign in to comment.