{"name":"template-toc","description":"Middleware for generating a markdown Table of Contents with Template or applications based on Template.","version":"0.3.2","homepage":"https://github.com/jonschlinkert/template-toc","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/template-toc.git"},"bugs":{"url":"https://github.com/jonschlinkert/template-toc/issues"},"license":{"type":"MIT","url":"https://github.com/jonschlinkert/template-toc/blob/master/LICENSE"},"files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"devDependencies":{"mocha":"*","should":"*","template":"^0.10.2"},"dependencies":{"extend-shallow":"^1.1.2","markdown-toc":"^0.11.0"},"keywords":["contents","docs","documentation","generate","insert","markdown","md","readme","table","template","toc"],"gitHead":"8bf84d8a219ada2e0c98f291d2426586a3c5e540","_id":"template-toc@0.3.2","_shasum":"1dd308929b3df13a272c39c19a4350dc82958ea8","_from":".","_npmVersion":"2.7.1","_nodeVersion":"1.6.2","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"1dd308929b3df13a272c39c19a4350dc82958ea8","tarball":"http://registry-npm.ywwl.com/template-toc/download/template-toc-0.3.2.tgz","integrity":"sha512-Vxkd5sFj6RrZ1rseBrNaPaeFLx+Vq+jSz788exCxoSGO7qNP9j0IHmUCfQbs+qzRxMfYZCNfuer+eHA2Xdi3hw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsLeFdPXrRvg1H9MQDJhVn7huxMyRSAY6N37XGeZCr+AIhAJ2uFodCY4qBYDXdn3WmwoWa1HkIG6GBkGoXmcLwohmj"}],"size":3506,"noattachment":false,"key":"/template-toc/-/template-toc-0.3.2.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":1427279501017,"_cnpm_publish_time":1427279501017,"dist-tags":{"latest":"0.6.2"}}