{"name":"rehype-slug","version":"3.0.0","description":"rehype plugin to add `id` attributes to headings","license":"MIT","keywords":["unified","rehype","rehype-plugin","plugin","html","heading","slug","id"],"repository":{"type":"git","url":"git+https://github.com/rehypejs/rehype-slug.git"},"bugs":{"url":"https://github.com/rehypejs/rehype-slug/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"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":"^2.0.0"},"devDependencies":{"browserify":"^16.0.0","nyc":"^15.0.0","prettier":"^1.0.0","rehype":"^9.0.0","remark-cli":"^7.0.0","remark-preset-wooorm":"^6.0.0","tape":"^4.0.0","tinyify":"^2.0.0","xo":"^0.28.0"},"scripts":{"format":"remark . -qfo && prettier --write \"**/*.js\" && xo --fix","build-bundle":"browserify index.js -s rehypeSlug > rehype-slug.js","build-mangle":"browserify index.js -s rehypeSlug -p tinyify > rehype-slug.min.js","build":"npm run build-bundle && npm run build-mangle","test-api":"node test","test-coverage":"nyc --reporter lcov tape test.js","test":"npm run format && npm run build && npm run test-coverage"},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"esnext":false,"ignores":["rehype-slug.js"]},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"76f382383e9af5a87fec7470b66b08e9598901b5","homepage":"https://github.com/rehypejs/rehype-slug#readme","_id":"rehype-slug@3.0.0","_nodeVersion":"13.10.1","_npmVersion":"6.14.2","dist":{"integrity":"sha512-zFnj5BCEJXV6+URwaz8yW+9BdjDwO5iVzlQui3+7cCJ9MXlIEL0IY8VefcT/03Gw+2Hutdrx+zXnS7bnOrepZg==","shasum":"8416257df9665981894a1f0cd42b13c407bbcc8e","tarball":"http://registry-npm.ywwl.com/rehype-slug/download/rehype-slug-3.0.0.tgz","fileCount":4,"unpackedSize":7329,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJebhkTCRA9TVsSAnZWagAAVLgP/14//ZHf2iRf0utAEssL\nkWr5Q82UbSftmpsdpXMkEJtBpuK9/u2dwXG5//8sySnciZvyPkD2LaSXV5uj\n7WKfHxdNb7CZx8FEJ6n4//vf0w4whkWNR/ZIocjNNGQzf+Yi6rsjVNxyYk29\nQKoRfUcj8MNeIcYN5IekxulM4U6Uun98M6w3NL8YfLJsXnOMEb6W8yYf779H\nT0SGmQFvwaCEKaUCAEPAkjoTDEfrE9kz3Y50q+1UB0DuWWaLvDeXdtoMQ9wZ\njDrUG7WpuwoemGuU0PTw8thKqgelWO0FizIsNntDXfvae8lW1hHohszXA+8T\nh6H7RnP6tjxjPulGqSmQ/IhvQ6I/3W2LDTrJabxJefxLmIJraIo/iM1GAZUn\nQQ0SK+H4DrRi08jytd3NN2h6e8JoGhTjtn+qhzeZUsGUZxRg4Tdno1dwiIXD\nl85+HVbjGJJ1+7J7nMSBaK/fujLLvd/BwGI3suzRZtsQ57MBeSFlLO7a0TGP\nTttsVXOABsJVzBzg4ElVcj2L12i7/NaJLpzqSrPcMqp390LiHl5W4JQwrMl1\nVMNY/aqp0C8l2ft2yDNSNm8vl3BGT+LxPzY9wV6fLvJCf/RISJ7WshT4b5iW\n1M1+pITw1j3CGuvSyTtOpVXAgJY4ranH6V/++/F7IVeHfxpQ0Aynid9LVckP\nCEYB\r\n=l6z4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDbNyddLhAV+MKw78VHbhhN3Yt/ijWH/LIk1ZS3KFuFzAiEA24+td123Nx7sJAQflU0+YXEHtLP7ZtGkSkwRTrhDGWY="}],"size":3247,"noattachment":false,"key":"/rehype-slug/-/rehype-slug-3.0.0.tgz"},"maintainers":[{"email":"keith@mcknig.ht","name":"kmck"},{"email":"tituswormer@gmail.com","name":"wooorm"}],"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rehype-slug_3.0.0_1584273683396_0.5615353706316335"},"_hasShrinkwrap":false,"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":1584273683529,"_cnpm_publish_time":1584273683529,"dist-tags":{"latest":"6.0.0"}}