{"name":"rehype-slug","version":"5.0.1","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"}],"sideEffects":false,"type":"module","types":"index.d.ts","main":"index.js","dependencies":{"@types/hast":"^2.0.0","github-slugger":"^1.1.1","hast-util-has-property":"^2.0.0","hast-util-heading-rank":"^2.0.0","hast-util-to-string":"^2.0.0","unified":"^10.0.0","unist-util-visit":"^4.0.0"},"devDependencies":{"@types/github-slugger":"^1.0.0","@types/tape":"^4.0.0","c8":"^7.0.0","prettier":"^2.0.0","rehype":"^12.0.0","remark-cli":"^10.0.0","remark-preset-wooorm":"^9.0.0","rimraf":"^3.0.0","tape":"^5.0.0","type-coverage":"^2.0.0","typescript":"^4.0.0","xo":"^0.47.0"},"scripts":{"build":"rimraf \"*.d.ts\" && tsc && type-coverage","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","test-api":"node --conditions development test.js","test-coverage":"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"gitHead":"22d2ab6d11faa250052a341e21c566705fc72e73","homepage":"https://github.com/rehypejs/rehype-slug#readme","_id":"rehype-slug@5.0.1","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"integrity":"sha512-X5v3wV/meuOX9NFcGhJvUpEjIvQl2gDvjg3z40RVprYFt7q3th4qMmYLULiu3gXvbNX1ppx+oaa6JyY1W67pTA==","shasum":"6e732d0c55b3b1e34187e74b7363fb53229e5f52","tarball":"http://registry-npm.ywwl.com/rehype-slug/download/rehype-slug-5.0.1.tgz","fileCount":5,"unpackedSize":10383,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzZ4DCRA9TVsSAnZWagAA6jMP/2/vL0RvIeIDlpf6nJyp\nl7e+/b0gs3FLGY2b2XtTahOTrd9MBp4Hr1ljp8hsSwIf/ZN3T3aDfdejdtzk\nbB9X/3uJJ0Ay0Dvh7JKl70GR+KIUAsC/N2gHhA3AFgQQVvYV4oAvAAqtqOWp\n6u0UorW0DOJBV1t7d0DJpv5uHg1nokQReLKYNlzsX2KiGS+IJeTTtJudJwV+\nptiAtFpJsiJW2CHVhnQs+6RHaAvsyq6VQyk3NHVBSL27Fzk9ftvLF+9mhRIu\nECdnkoymxQwNxXn7MG9mcbV0fN5vo0lMaMEDSyjQVlfgFMBl8XWMdSg6SLNH\n7wgeO4TooG0NsKq2kRehN2h8xDFhCLrJ86/3feXJubnZMa9+JVx9q7G+67BW\nLBTljmlqyEYasZURp9IrxgU9QbyX5kFloatBG0MhDLX6+4p/35VYF/We9Ph6\ngTzaP831AzbK8gSJIYxqfVHOF0Cn18Stquaa8R/xwHwJAhTZ8GGDLCiAU1sg\n3dbIANXBm7+uLGzgPrevRMAAxEm3lxsA33hJqOjsJVFYKd6SDFQpt/bljht6\nRXV9c3ylvNjN/CGl9ufZ6RooC0UN8PrmruXBq1qGhcF/RFo16iHE4TMejXoS\n7sFPard0E70Mr5KB21cplC/rZSq6pnRTrzRbMiRoMylWk9ADO0S9GIZjrHRZ\nd6sA\r\n=nDNE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCZ/3nmCYEs9+RrvPvXrgYvRSC3JTLqLqpkj8HiJdoX7wIhAMqE6L/v67XJ66qb5OifagNm/RsywFkx5uH+h2KcRnjM"}],"size":4290,"noattachment":false,"key":"/rehype-slug/-/rehype-slug-5.0.1.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"kmck","email":"keith@mcknig.ht"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rehype-slug_5.0.1_1640865283662_0.1349310518047302"},"_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":1640865283796,"_cnpm_publish_time":1640865283796,"dist-tags":{"latest":"6.0.0"}}