{"name":"template-toc","description":"Middleware for generating a markdown-formatted table of contents with Template, or Template-based applications","version":"0.5.1","homepage":"https://github.com/jonschlinkert/template-toc","author":{"name":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/template-toc.git"},"bugs":{"url":"https://github.com/jonschlinkert/template-toc/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","is-primitive":"^2.0.0","markdown-toc":"^0.11.7"},"devDependencies":{"assemble-loader":"^0.2.4","engine-base":"^0.1.2","mocha":"*","should":"*","templates":"^0.6.3"},"keywords":["contents","docs","documentation","generate","insert","markdown","md","readme","table","template","toc"],"verb":{"related":{"list":["remarkable","markdown-toc","markdown-utils","verb","template"]}},"gitHead":"cbb6e5455eb1e4879b4ef20e17c15301e6b1e28c","_id":"template-toc@0.5.1","_shasum":"151c46e318f9c79131ac944ca69dbd88c7508da9","_from":".","_npmVersion":"3.3.6","_nodeVersion":"5.0.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"151c46e318f9c79131ac944ca69dbd88c7508da9","tarball":"http://registry-npm.ywwl.com/template-toc/download/template-toc-0.5.1.tgz","integrity":"sha512-LMQA2f9bMxvVVgrwz2F+DBKeFuqCYA1H5jGF5046faWbotvr43JMpObHrladDQb+vWQ0Si9xWDukwc/rb5oNFA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCA76PVVMFnuecCtD7NtCU4RzpMeNxThsPdc7iLQVT68AIgZaPmP+C5W/Rizx2kttJbTV7+I2jR/7rCaenqdjKK2y8="}],"size":3685,"noattachment":false,"key":"/template-toc/-/template-toc-0.5.1.tgz"},"directories":{},"readme":"# template-toc [![NPM version](https://img.shields.io/npm/v/template-toc.svg)](https://www.npmjs.com/package/template-toc) [![Build Status](https://img.shields.io/travis/jonschlinkert/template-toc.svg)](https://travis-ci.org/jonschlinkert/template-toc)\n\n> Middleware for generating a markdown-formatted table of contents with Template, or Template-based applications\n\n<!-- toc -->\n\n* [Install](#install)\n* [Usage](#usage)\n  - [Two Steps](#two-steps)\n  - [Templates.js](#templatesjs)\n  - [Verb](#verb)\n  - [Assemble](#assemble)\n* [Pro-tip](#pro-tip)\n* [Related projects](#related-projects)\n* [Running tests](#running-tests)\n* [Contributing](#contributing)\n* [Author](#author)\n* [License](#license)\n\n_(TOC generated by [verb](https://github.com/verbose/verb))_\n\n<!-- tocstop -->\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm i template-toc --save\n```\n\n## Usage\n\n```js\nvar toc = require('template-toc');\n```\n\n### Two Steps\n\n**1. [Register the middleware](#usage-with-template)**\n\nRegister with [templates](https://github.com/jonschlinkert/templates), [verb](https://github.com/verbose/verb), [assemble](http://assemble.io) or any other application based on [templates](https://github.com/jonschlinkert/templates)\n\n**2. Add a TOC marker**\n\nAdd the following to any markdown file that should get a Table of Contents:\n\n```html\n<!-- toc -->\n```\n\n### Templates.js\n\nUsage with [template.js](https://github.com/jonschlinkert/templates):\n\n```js\nvar Templates = require('templates');\nvar templates = new Templates();\n```\n\n**Pre-render middleware**\n\nIf you want the TOC to be generated before layouts are used or partials are injected into pages, use the `.preRender()` method.\n\n```js\ntemplates.preRender(/\\.md$/, toc(template));\n```\n\nThis project's [verbfile](./.verb.md) is a good example. Verb uses this middleware with `.preRender()` so that the generated TOC only includes \"top-level\" headings that are in the template, and none of the headings from partials are includes.\n\n**Post-render middleware**\n\nIf you want the TOC to be generated **after** layouts are used or partials are injected into pages, use the `.postRender()` method.\n\n```js\ntemplates.postRender(/\\.md$/, toc(template));\n```\n\n**Rendering templates**\n\nOnce the middlware is setup, any templates with a `.md` extension and a `<!-- toc -->` comment will have a TOC injected.\n\n```js\ntemplates.render('README.md', function(err, content) {\n  console.log(content);\n});\n```\n\nVisit [templates](https://github.com/jonschlinkert/templates) for documentation.\n\n### Verb\n\nUsage with [verb](https://github.com/verbose/verb):\n\n```js\nvar verb = require('verb'); // or assemble\nvar app = verb();\n\napp.preRender(/\\.md$/, toc(app));\n// or \napp.postRender(/\\.md$/, toc(app));\n```\n\nVisit [verb](https://github.com/verbose/verb) for documentation.\n\n### Assemble\n\nUsage with [assemble](http://assemble.io):\n\n```js\nvar assemble = require('assemble'); \nvar app = assemble();\n\napp.preRender(/\\.md$/, toc(app));\n// or \napp.postRender(/\\.md$/, toc(app));\n```\n\nVisit [assemble](http://assemble.io) for documentation.\n\n## Pro-tip\n\n**Escaping**\n\nIf, for some reason, you need to use the `<!- toc -->` comment in documentation and you do not want it to be rendered, just add an extra `!` after the first angle bracket, and the extra `!` will be removed but the TOC will not be rendered.\n\n```html\n<!-- toc -->\n```\n\n## Related projects\n\n* [markdown-toc](https://www.npmjs.com/package/markdown-toc): Generate a markdown TOC (table of contents) with Remarkable. | [homepage](https://github.com/jonschlinkert/markdown-toc)\n* [markdown-utils](https://www.npmjs.com/package/markdown-utils): Micro-utils for creating markdown snippets. | [homepage](https://github.com/jonschlinkert/markdown-utils)\n* [remarkable](https://www.npmjs.com/package/remarkable): Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in… [more](https://www.npmjs.com/package/remarkable) | [homepage](https://github.com/jonschlinkert/remarkable)\n* [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine.… [more](https://www.npmjs.com/package/templates) | [homepage](https://github.com/jonschlinkert/templates)\n* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://www.npmjs.com/package/verb) | [homepage](https://github.com/verbose/verb)\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm i -d && npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/template-toc/issues/new).\n\n## Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\n\nCopyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb) on December 15, 2015._","publish_time":1450184890259,"_cnpm_publish_time":1450184890259,"dist-tags":{"latest":"0.6.2"}}