{"name":"markdown-it-named-headers","version":"0.0.2","description":"Headers have name attributes for markdown-it.","keywords":["markdown-it-plugin"],"homepage":"https://github.com/leff/markdown-it-named-headers","license":{"type":"Unlicense","url":"http://unlicense.org/"},"author":{"name":"Jason Brackins"},"files":["README.md","UNLICENSE","index.js"],"repository":{"type":"git","url":"https://github.com/leff/markdown-it-named-headers"},"dependencies":{"string":"^3.0.1"},"devDependencies":{"markdown-it":"^4.0.1","mocha":"^2.2.1","test":">=0.0.1"},"scripts":{"test":"mocha test/all.js"},"gitHead":"95d902415a06c5c12607bf505f41a4f0fcf3983f","bugs":{"url":"https://github.com/leff/markdown-it-named-headers/issues"},"_id":"markdown-it-named-headers@0.0.2","_shasum":"726a87a5ad62624a65a80751fb209576556ba681","_from":".","_npmVersion":"2.0.0-alpha-5","_npmUser":{"name":"leff","email":"jason.brackins@gmail.com"},"maintainers":[{"name":"leff","email":"jason.brackins@gmail.com"}],"dist":{"shasum":"726a87a5ad62624a65a80751fb209576556ba681","tarball":"http://registry-npm.ywwl.com/markdown-it-named-headers/download/markdown-it-named-headers-0.0.2.tgz","integrity":"sha512-59VxPuXJM9h+/HgC8+CUdbPVsAA9r6012PXDKBi28U3gWxfDzAkw7/R9B8L3qjReaBxNJJB0Vobnc99Iz8kmmg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGZKaf0DzNOYficiUgbfSoNePpyVNQwpbjmHZO/c0cDrAiAt/eiEb8r5zRCOx2uBQnJedPM389j7NBnTMmgSC0/i4w=="}],"size":2026,"noattachment":false,"key":"/markdown-it-named-headers/-/markdown-it-named-headers-0.0.2.tgz"},"readme":"# Markdown-it Named Headers\r\n\r\nA plugin for [markdown-it](https://github.com/markdown-it/markdown-it). Makes header elments have identifer attributes.\r\n\r\n```\r\n# Example Header   -->   <h1 id=\"example-header\">Example</h1>\r\n```\r\n\r\nBy default, it uses [string.js](http://stringjs.com/)'s [slugify](http://stringjs.com/#methods/slugify) to translate header text into a url safe name. You can override this. See _Options_.\r\n\r\nCribbed heavily from https://github.com/valeriangalliat/markdown-it-anchor\r\n\r\n## Install\r\n\r\n```\r\nnpm install --save-dev markdown-it-named-headers\r\n```\r\n\r\n## Usage\r\n\r\nUse with plain old node:\r\n\r\n```js\r\nvar md   = require('markdown-it'),\r\n    mdnh = require('markdown-it-named-headers');\r\n\r\nmd.use(mdnh, options);\r\n```\r\n\r\nUse as part of a Gulp workflow: (Note: You don't need to require named-headers in your gulpfile. gulp-markdown-it takes care of that for you).\r\n\r\n```js\r\nvar gulp = require('gulp'),\r\n    md = require('gulp-markdown-it');\r\ngulp.task('md', [], function() {\r\n    return gulp.src( '**/*.md' )\r\n        .pipe(md({\r\n            plugins: ['markdown-it-named-headers']\r\n        }))\r\n        .pipe(gulp.dest('dist'));\r\n});\r\n```\r\n\r\n\r\n### Options\r\n\r\n\r\n#### Slugify\r\n\r\n```js\r\n{\r\n   slugify: my_slug_function\r\n}\r\n```\r\n\r\nIf string.js's slugify doesn't fit your needs, you can simply pass in your own slugify function. Basically, the API is: accept any string, return a string suitable for a name attribute. Example:\r\n\r\n```js\r\nfunction slugify(input_string) {\r\n    var output_string = my_transform_logic(input_string);\r\n    return output_string;\r\n}\r\n```\r\n\r\nSince we use IDs, we should avoid duplicating them. A second parameter is passed. It is an empty object that will persist across a single call to render. In other words, you can use it to maintain a hash of used_headers per page.\r\n\r\nThe default slugify method looks something like this:\r\n\r\n```js\r\nfunction slugify(input_string, used_headers) {\r\n  var slug = string(input_string).slugify().toString();\r\n  if( used_headers[slug] ) {\r\n    used_headers[slug]++;\r\n    slug += used_headers[slug];\r\n  } else {\r\n    used_headers[slug] += '-' + 1;\r\n  }\r\n  return slug;\r\n}\r\n```\r\n","publish_time":1427390968249,"_cnpm_publish_time":1427390968249,"dist-tags":{"latest":"0.0.4"}}