{"name":"marked-toc","description":"Generate a markdown TOC (table of contents), using the [marked.js](https://github.com/chjj/marked) lexer and parser.","version":"0.2.1","homepage":"https://github.com/jonschlinkert/marked-toc","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"https://github.com/jonschlinkert/marked-toc.git"},"bugs":{"url":"https://github.com/jonschlinkert/marked-toc/issues"},"licenses":[{"type":"MIT","url":"https://github.com/jonschlinkert/marked-toc/blob/master/LICENSE-MIT"}],"bin":{"toc":"./bin/toc"},"main":"index.js","engines":{"node":">= 0.8.0"},"devDependencies":{"chai":"~1.9.0","mocha":"~1.17.1"},"dependencies":{"fs-utils":"~0.2.1","globule":"~0.2.0","lodash":"~2.4.1","marked":"~0.3.1","template":"~0.1.5","uslug":"~1.0.3","relative":"~0.1.0","chalk":"~0.4.0","gray-matter":"~0.2.3"},"keywords":["readme","markdown","toc","table of contents"],"_id":"marked-toc@0.2.1","dist":{"shasum":"dfb663b052cd62924d37e41b84a758468aaa4976","tarball":"http://registry-npm.ywwl.com/marked-toc/download/marked-toc-0.2.1.tgz","integrity":"sha512-9sUA+n0qhRRw8GqsAreOLMga7yT6NslNT/JhX3HZ4fd7yeQQKML2msqkFLA14wyxAHy7pNINoY4kNvau+ftrmQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDE+uj5HbGHcVO1UrTFQ/rTdDU32Dp2lUb3wPxKaJjb4AiEAxWx/weSKKkdv0/5yPDYmJ27n39x+ZiFFb5Cfkje3NXg="}],"size":19189,"noattachment":false,"key":"/marked-toc/-/marked-toc-0.2.1.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"directories":{},"readme":"# marked-toc [![NPM version](https://badge.fury.io/js/marked-toc.png)](http://badge.fury.io/js/marked-toc)\n\n> Generate a TOC (table of contents) for markdown files\n\n_(example)_\n<!-- toc -->\n* [Getting Started](#getting-started)\n* [Usage](#usage)\n* [Options](#options)\n  * [template](#template)\n  * [bullet](#bullet)\n  * [maxDepth](#maxdepth)\n  * [firsth1](#firsth1)\n  * [omit](#omit)\n  * [clean](#clean)\n  * [blacklist](#blacklist)\n  * [allowedChars](#allowedchars)\n* [API](#api)\n  * [toc](#toc)\n  * [toc.insert](#tocinsert)\n  * [toc.add](#tocadd)\n  * [toc.raw](#tocraw)\n* [Contributing](#contributing)\n* [Author](#author)\n* [License](#license)\n\n<!-- toc stop -->\n\n## Getting Started\n\nInstall the module with [npm](npmjs.org):\n\n```bash\nnpm i -g marked-toc --save\n```\n\nIn any markdown file, add `<!-- toc -->` where you want to add the TOC. Then in the command line, run:\n\n```bash\ntoc [filename]\n```\n\nIf you add the toc to a `README.md`, no need to add `[filename]`, just run `toc`.\n\n\n## Usage\n\n```javascript\nvar toc = require('marked-toc');\nvar file = fs.readFileSync('README.md', 'utf8');\n\n// Generate a TOC\ntoc(file);\n```\n\n## Options\n\nAll methods accept an object of options as the last argument.\n\n### template\n\nType: `String`\n\nDefault: `<%= depth %><%= bullet %>[<%= heading %>](#<%= url %>)\\n`\n\nThe Lo-Dash template used to generate the Table of Contents.\n\n**Example (this is the default):**\n\n```js\nvar tmpl = '<%= depth %><%= bullet %>[<%= heading %>](#<%= url %>)\\n';\ntoc(file, {template: tmpl});\n```\n\n### bullet\n\nType: `String|Array`\n\nDefault: `* `\n\nThe bullet to use for each item in the generated TOC. This is passed as a variable to the `<%= bullet %>` template.\n\nIf an array, like `['* ', '- ']`, the bullet point strings will be used based on the header depth.\n\n\n### maxDepth\n\nType: `Number`\n\nDefault: `3`\n\nUse headings whose depth is at most maxDepth.\n\n\n### firsth1\n\nType: `Boolean`\n\nDefault: `False`\n\nInclude the first h1-level heading in a file. For example, this prevent the first heading in a README from showing up in the TOC.\n\n\n### omit\n\nType: `Array`\n\nDefault: `['Table of Contents', 'TOC', 'TABLE OF CONTENTS']`\n\nOmit entire headings from the TOC if they have these strings.\n\n### clean\n\nType: `Array`\n\nDefault: `['mixin', 'helper', 'filter']`\n\nStrip \"blacklisted\" keywords from the headings.\n\n**Example:**\n\n```js\ntoc(file, {clean: ['docs', 'methods']});\n```\n\nconverts this:\n\n```markdown\n## docs-foo\nFoo\n\n## methods-bar\nBar\n\n```\nto:\n\n```markdown\n* [foo](#docs-foo)\n* [bar](#methods-bar)\n\n```\n\n### blacklist\n\nType: `Boolean`\n\nDefault: `true`\n\nAn array of strings used the `omit` option:\n\n```js\n['grunt', 'helper', 'handlebars-helper', 'mixin', 'filter', 'assemble-contrib', 'assemble']\n```\n\n_(These strings are used a lot in documentation headings, but (usually) shouldn't show up in the gererated TOC.)_\n\n\n### allowedChars\n\nType: `String`\n\nDefault: `-`\n\nString of chars that you want to be whitelisted when headings are \"slugified\" for links, e.g. `-_~`.\n\n**Example:**\n\n```markdown\n// This heading\n# Getting Started\n\n// Converts to this link\n* [Getting Started](#getting-started)\n\n```\n\n## API\n\nMost methods expect a string as the first paramter, so unless otherwise noted, assume that each example gets the `str` variable from:\n\n\n```js\nvar str = fs.readFileSync('README.md', 'utf8')\n```\n\n### toc\n\nGenerates a Table of Contents from a string.\n\n```js\n// Generate a TOC\nvar table = toc(str);\nfs.writeFileSync('toc.md', table);\n```\n\n### toc.insert\n\nInject a TOC at the insertion point in a string, `<!-- toc -->`.\n\n**Params:**\n\n* `str`: the content\n* `options`: object of options\n\n```js\ntoc.insert(str, options);\n```\n\n### toc.add\n\n1. Read a file and inject a TOC at the specified insertion point, `<!-- toc -->`,\n2. Write the file to the specified `dest`, _(or re-write back to the source file if no `dest` is passed)_\n\n```js\ntoc.add(src, dest, options)\n```\n\n**Example:**\n\n```js\ntoc.add('path/to/source.md', 'path/to/dest.md');\n```\n\n**Source only:**\n\n```js\ntoc.add('README.md');\n```\n\n### toc.raw\n\nOutput a \"raw\" (JSON) Table of Contents **object**, for customization and usage in templates\n\n```js\ntoc.raw(str, options);\n```\n\nReturns an object (JSON) with two properties, `data` and `toc`:\n\n* `data`: array of headings and associated properties used to construct a TOC. **TIP**: this can be extended with properties, such as src path etc.\n* `toc`: the actual Table of Contents result, as a string\n\n**Example:**\n\n```json\n{\n  // Array of\n  \"data\": [\n    {\n      \"depth\": \"\",\n      \"bullet\": \"* \",\n      \"heading\": \"Getting Started\",\n      \"url\": \"getting-started\"\n    },\n    {\n      \"depth\": \"\",\n      \"bullet\": \"* \",\n      \"heading\": \"Usage\",\n      \"url\": \"usage\"\n    }\n  ],\n\n  // String. the actual TOC\n  \"toc\": \"* [Getting Started](#getting-started)\\n* [Options](#options)\\n* [Contributing](#contributing)\\n\"\n}\n```\n\nSee [an example](./examples/toc.json).\n\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code using [jshint](jshint.com) and run tests with `mocha -R spec` before making a pull request.\n\n## Author\n\n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n## License\nCopyright (c) 2014 Jon Schlinkert, contributors\nLicensed under the MIT license.\n","publish_time":1391458486598,"_cnpm_publish_time":1391458486598,"dist-tags":{"latest":"0.3.0"}}