From 9bf262c92eae3ff35f00d7571211958f051a76ee Mon Sep 17 00:00:00 2001 From: Sethen Date: Thu, 5 Mar 2015 23:21:44 -0500 Subject: [PATCH] Changed markdown.json options, added heading option for table of contents --- README.md | 14 ++++++++------ docs/how_to_use.md | 12 ++++++------ markdown-include.js | 8 +++++++- markdown.json | 4 +++- package.json | 2 +- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b61b8ba..74c0e35 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/docs/how_to_use.md b/docs/how_to_use.md index bc46ee6..afaea0c 100644 --- a/docs/how_to_use.md +++ b/docs/how_to_use.md @@ -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) | \ No newline at end of file diff --git a/markdown-include.js b/markdown-include.js index 9496c87..19b14cb 100644 --- a/markdown-include.js +++ b/markdown-include.js @@ -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); diff --git a/markdown.json b/markdown.json index f44dc94..0058b22 100644 --- a/markdown.json +++ b/markdown.json @@ -1,5 +1,7 @@ { "build" : "README.md", "files" : ["./docs/_README.md"], - "tableOfContents": true + "tableOfContents": { + "heading": "# Table of Contents" + } } \ No newline at end of file diff --git a/package.json b/package.json index 81c95dd..9fae592 100644 --- a/package.json +++ b/package.json @@ -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": {