{"name":"rehype-slug","version":"2.0.0","description":"Add id attributes to headings","license":"MIT","keywords":["rehype","plugin","slug","id"],"repository":{"type":"git","url":"git+https://github.com/wooorm/rehype-slug.git"},"bugs":{"url":"https://github.com/wooorm/rehype-slug/issues"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"}],"files":["index.js"],"dependencies":{"github-slugger":"^1.1.1","hast-util-has-property":"^1.0.0","hast-util-is-element":"^1.0.0","hast-util-to-string":"^1.0.0","unist-util-visit":"^1.1.0"},"devDependencies":{"browserify":"^14.1.0","esmangle":"^1.0.0","nyc":"^10.0.0","rehype":"^4.0.0","remark-cli":"^3.0.0","remark-preset-wooorm":"^2.0.0","tape":"^4.0.0","xo":"^0.17.0"},"scripts":{"build-md":"remark . -qfo","build-bundle":"browserify index.js --bare -s rehypeSlug > rehype-slug.js","build-mangle":"esmangle rehype-slug.js > rehype-slug.min.js","build":"npm run build-md && npm run build-bundle && npm run build-mangle","lint":"xo","test-api":"node test.js","test-coverage":"nyc --reporter lcov tape test.js","test":"npm run build && npm run lint && npm run test-coverage"},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"xo":{"space":true,"ignores":["rehype-slug.js"]},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"1c00a07313eb95467ac500703cac57c8435dfe1c","homepage":"https://github.com/wooorm/rehype-slug#readme","_id":"rehype-slug@2.0.0","_shasum":"b52f6c69faefc61420cb9ea8ba268e48531c61b9","_from":".","_npmVersion":"4.0.3","_nodeVersion":"7.0.0","_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"dist":{"shasum":"b52f6c69faefc61420cb9ea8ba268e48531c61b9","tarball":"http://registry-npm.ywwl.com/rehype-slug/download/rehype-slug-2.0.0.tgz","integrity":"sha512-SnJt6KhumH6xF9ATXNWzofo9L6pt/oKod6KhBUstRZrKmWvK/QLRxQNmyi7upIGqBbLdAlE/5+U20hS9rXuQdg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQClzPTrhaRessulV3dgS24vJLLMOwAiU9EWAslJDk14dwIgLTN6b9uo1TghR51ol597UQk8prT3pHireS2gva0sq1M="}],"size":2511,"noattachment":false,"key":"/rehype-slug/-/rehype-slug-2.0.0.tgz"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/rehype-slug-2.0.0.tgz_1487884982996_0.9367646840400994"},"directories":{},"readme":"# rehype-slug\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n**[rehype][]** plugin to add `id`s to headings.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`unified().use(rehypeSlug[, options])`](#unifieduserehypeslug-options)\n    *   [`Options`](#options)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package is a [unified][] ([rehype][]) plugin to add `id`s to headings.\nIt looks for headings (so `<h1>` through `<h6>`) that do not yet have `id`s\nand adds `id` attributes to them based on the text they contain.\nThe algorithm that does this is [`github-slugger`][github-slugger], which\nmatches how GitHub works.\n\n**unified** is a project that transforms content with abstract syntax trees\n(ASTs).\n**rehype** adds support for HTML to unified.\n**hast** is the HTML AST that rehype uses.\nThis is a rehype plugin that adds `id`s to headings in the AST.\n\n## When should I use this?\n\nThis plugin is useful when you have relatively long documents and you want to be\nable to link to particular sections.\n\nA different plugin, [`rehype-autolink-headings`][rehype-autolink-headings], adds\nlinks to these headings back to themselves, which is useful as it lets users\nmore easily link to particular sections.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install rehype-slug\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport rehypeSlug from 'https://esm.sh/rehype-slug@6'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import rehypeSlug from 'https://esm.sh/rehype-slug@6?bundle'\n</script>\n```\n\n## Use\n\nSay we have the following file `example.html`:\n\n```html\n<h1 id=some-id>Lorem ipsum</h1>\n<h2>Dolor sit amet 😪</h2>\n<h3>consectetur &amp; adipisicing</h3>\n<h4>elit</h4>\n<h5>elit</h5>\n```\n\n…and our module `example.js` looks as follows:\n\n```js\nimport {read} from 'to-vfile'\nimport {rehype} from 'rehype'\nimport rehypeSlug from 'rehype-slug'\n\nconst file = await rehype()\n  .data('settings', {fragment: true})\n  .use(rehypeSlug)\n  .process(await read('example.html'))\n\nconsole.log(String(file))\n```\n\n…then running `node example.js` yields:\n\n```html\n<h1 id=\"some-id\">Lorem ipsum</h1>\n<h2 id=\"dolor-sit-amet-\">Dolor sit amet 😪</h2>\n<h3 id=\"consectetur--adipisicing\">consectetur &#x26; adipisicing</h3>\n<h4 id=\"elit\">elit</h4>\n<h5 id=\"elit-1\">elit</h5>\n```\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`rehypeSlug`][api-rehype-slug].\n\n### `unified().use(rehypeSlug[, options])`\n\nAdd `id`s to headings.\n\n###### Parameters\n\n*   `options` ([`Options`][api-options], optional)\n    — configuration\n\n###### Returns\n\nTransform ([`Transformer`][unified-transformer]).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n*   `prefix` (`string`, default: `''`)\n    — prefix to add in front of `id`s\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Options`][api-options].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `rehype-slug@^6`,\ncompatible with Node.js 16.\n\nThis plugin works with `rehype-parse` version 1+, `rehype-stringify` version 1+,\n`rehype` version 1+, and `unified` version 4+.\n\n## Security\n\nUse of `rehype-slug` can open you up to a [cross-site scripting (XSS)][xss]\nattack as it sets `id` attributes on headings, which causes what is known\nas “DOM clobbering”.\nPlease use [`rehype-sanitize`][rehype-sanitize] and see its\n[Example: headings (DOM clobbering)][rehype-sanitize-example] for information on\nhow to properly solve it.\n\n## Related\n\n*   [`rehype-autolink-headings`][rehype-autolink-headings]\n    — add links to headings with IDs back to themselves\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways\nto get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/rehypejs/rehype-slug/workflows/main/badge.svg\n\n[build]: https://github.com/rehypejs/rehype-slug/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-slug.svg\n\n[coverage]: https://codecov.io/github/rehypejs/rehype-slug\n\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-slug.svg\n\n[downloads]: https://www.npmjs.com/package/rehype-slug\n\n[size-badge]: https://img.shields.io/bundlejs/size/rehype-slug\n\n[size]: https://bundlejs.com/?q=rehype-slug\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/rehypejs/rehype/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[health]: https://github.com/rehypejs/.github\n\n[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md\n\n[support]: https://github.com/rehypejs/.github/blob/main/support.md\n\n[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[github-slugger]: https://github.com/Flet/github-slugger\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[rehype-autolink-headings]: https://github.com/rehypejs/rehype-autolink-headings\n\n[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize\n\n[rehype-sanitize-example]: https://github.com/rehypejs/rehype-sanitize#example-headings-dom-clobbering\n\n[typescript]: https://www.typescriptlang.org\n\n[unified]: https://github.com/unifiedjs/unified\n\n[unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[api-options]: #options\n\n[api-rehype-slug]: #unifieduserehypeslug-options\n","publish_time":1487884983590,"_cnpm_publish_time":1487884983590,"dist-tags":{"latest":"6.0.0"}}