{"_id":"rehype-slug-custom-id","_rev":"3-1df1d71c4a8722fd947ddbe45d578237","name":"rehype-slug-custom-id","description":"plugin to add `id` attributes to headings similar to gatsby-remark-autolink-headers ","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"rehype-slug-custom-id","version":"1.0.0","keywords":["unified","rehype","rehype-plugin","plugin","html","heading","slug","id"],"license":"MIT","_id":"rehype-slug-custom-id@1.0.0","maintainers":[{"name":"crutchcorn","email":"crutchcorn@gmail.com"}],"homepage":"https://github.com/unicorn-utterances/rehype-slug-custom-id#readme","bugs":{"url":"https://github.com/unicorn-utterances/rehype-slug-custom-id/issues"},"xo":{"prettier":true},"dist":{"shasum":"fdc9660835c2fa765db667e7a3d0d3e77b93ece9","tarball":"https://registry.npmjs.org/rehype-slug-custom-id/-/rehype-slug-custom-id-1.0.0.tgz","fileCount":5,"integrity":"sha512-gt8KAAXLtH3Fd8zZrQZx8DZogLZImrHc0jjwQQoGYtXV8cnb5O2veSQ3ArwdgAFzzM9fC+bycWR8Qw39Z14NHA==","signatures":[{"sig":"MEQCIEO9FTMonv9pNnM9YSgMvUHcy6/YZ+EZ9u1Ox0icfO8EAiAs6pRiaPFzrwyGNTLP4N+KFGxuwEw9AKvAsguy9q5mkg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9280,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKnYaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpgXA/7BaPG4ezLiSjV1ktA7Z6xfkWv7L80m3xg4WQesXKJPz4xXGVV\r\n76dCsNW/YuZtRWapQUUAYHrUJ67SJ6811Dr7DvKUKeQMstLgBM9ykIRjOCnX\r\nePVhbRPgyBJyE6hNkzizUVuDm9O65yAYPoBLSjS0ouqD/MvOYySEz8ppcIMP\r\nk+Wmo/zUGjZZeHROuIg7lld1ieZ9ZyuXAK56JlYuypC/0iCYJpEZ+UeC8Vjd\r\nf30i6iXNY741RjsZ8n6P7619CuCzg/QXwoGPUlE0O2XUGPibRDF/hQzzx3Be\r\n8JoPeOK6OwVN82qYTE+zixdHDyEJTLF1ck/6jGNF+6OLc42UPsyRJxkJ8ieD\r\nNfKRHR620vi6a8ElFhIAYxdc7u3gvCYQX+TpRFHDldr6rgVBqfs4vvnHnJbQ\r\nf1yp8QCx54NwMIcB7jcLtKidd0EyV3VjFVZV9ah601pR7MFa4BvfbbmWNOip\r\nnzmddm/RMrUGDhduNZKvxLmu3TEM0SI44TuVozQgggAR/6bq+iI1LuB7jxxR\r\n32tCzpH3GhtwbbRl3E+/h9PY3Cg96P2eI0bJn6kBxx1kuXgEbd10BA7uQKFS\r\nEK5ljpzXs0IojI6ASfkWIrEWrM24i4iu2DTCeCLKoGoch0L3LsCK7OzW0e77\r\nPBjqdVKmGhaH9ySM7cNAw7kMmoA8ctVCdeQ=\r\n=YJr5\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","type":"module","types":"index.d.ts","gitHead":"66affdc631431578fff6528d114e937681268d57","scripts":{"test":"npm run build && npm run format && npm run test-coverage","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"},"_npmUser":{"name":"crutchcorn","email":"crutchcorn@gmail.com"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"singleQuote":true,"trailingComma":"none","bracketSpacing":false},"repository":{"url":"git+https://github.com/unicorn-utterances/rehype-slug-custom-id.git","type":"git"},"_npmVersion":"8.1.2","description":"plugin to add `id` attributes to headings similar to gatsby-remark-autolink-headers ","directories":{},"sideEffects":false,"_nodeVersion":"16.13.1","dependencies":{"lodash":"^4.17.21","unified":"^10.0.0","@types/hast":"^2.0.0","github-slugger":"^1.1.1","unist-util-visit":"^4.0.0","hast-util-to-string":"^2.0.0","hast-util-has-property":"^2.0.0","hast-util-heading-rank":"^2.0.0"},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"detail":true,"strict":true,"atLeast":90,"ignoreCatch":true},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.0.0","xo":"^0.44.0","tape":"^5.0.0","rehype":"^12.0.0","rimraf":"^3.0.0","prettier":"^2.0.0","remark-cli":"^10.0.0","typescript":"^4.0.0","@types/tape":"^4.0.0","@types/lodash":"^4.14.177","type-coverage":"^2.0.0","remark-preset-wooorm":"^9.0.0","@types/github-slugger":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rehype-slug-custom-id_1.0.0_1646949913966_0.6645124094170891","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"rehype-slug-custom-id","version":"1.1.0","keywords":["unified","rehype","rehype-plugin","plugin","html","heading","slug","id"],"license":"MIT","_id":"rehype-slug-custom-id@1.1.0","maintainers":[{"name":"crutchcorn","email":"crutchcorn@gmail.com"}],"homepage":"https://github.com/unicorn-utterances/rehype-slug-custom-id#readme","bugs":{"url":"https://github.com/unicorn-utterances/rehype-slug-custom-id/issues"},"xo":{"prettier":true},"dist":{"shasum":"56fe346244da033cbf33efa764b1351c993b6960","tarball":"https://registry.npmjs.org/rehype-slug-custom-id/-/rehype-slug-custom-id-1.1.0.tgz","fileCount":5,"integrity":"sha512-lLdTHGd7u5bOXRDnD78/VHrVZsG63nN6lZUuQgcuupGt1+v+uDW7pCeQS0cvptRcZPYzg8B+0bf8sUiMBKsjZw==","signatures":[{"sig":"MEYCIQCGKQk6SaPpiuO8HgfBGafE6PLWY9nRqleIm5+Cagr/HAIhAPnhFCUPQohhEWpiCdtf7Th0ObJTdML0jIYsabQcJidt","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10132,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKtH6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrOFg//b14gjccS5lJdjq/U2sbdPFObCXBBFW3PIjfJt+ZgW+tvoycj\r\nUer7Z6VksfRStvSCWGMYI5IxYNO/sFZqyRY2wkWSS7zSEpjSahHcEnD93nPn\r\nS/GBZ0SazGlmYF0kFIobO52aMlAtzPlSOv2dYDBxnAWfwSNQb/aWucCWTCng\r\n1cHUnRHRKOID2bk/L5v2xPeD2yPGe2GuayCYfyOM2CHQI6WaBpvoEtheHmFJ\r\nmKp/8R1WdBV/dumZCdwHDYYeKdxHnylk3x1joVN8yYB0EbPWl0GYEBXDlyuv\r\nFgZpbxKFHabUC4RoVRwIUcC5f4gUBrjC7NFj6jVLPAyWgszfnFw6aeO31mLB\r\nAsoTU28uWYSElLqsVLQmOaXk/tqQ6lPBD3RbiVhKOR1+d4hF/z9mPd7HDuLO\r\np1sHEkA0ZNja8XXgoVV+IZpFEYqEDaqkDWazsBYds58kY8gTUet7/S8UXw5k\r\nw0YqdDJsB0ALXFB7IjFCrVqzp1ez8toXNZSrArmTE54/I9i7/qpZFJxWqaq7\r\nzDyk5LnTrFgVBHwsumjOCSVI9meGdWsM5zsiL72/NkDF9cij1jOjHDR6cIWs\r\nOZmbVxEOPKmcdMLkinjD6vkaIdUvciJNbx8yAl17gstoFLjPJHhlJpF8goUV\r\nYGlA/XV5T74X9CMHOHXRfg80WBMYd7Zq7sQ=\r\n=y5ta\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","type":"module","types":"index.d.ts","gitHead":"14fd1f3630ec3fb984b1d6c548f58681e514da0c","scripts":{"test":"npm run build && npm run format && npm run test-coverage","build":"rimraf \"*.d.ts\" && tsc && type-coverage","format":"remark . -qo && prettier . -w --loglevel warn && xo --fix","test-api":"node --conditions development test.js","test-coverage":"c8 --check-coverage --branches 80 --functions 90 --lines 90 --statements 90 --reporter lcov npm run test-api"},"_npmUser":{"name":"crutchcorn","email":"crutchcorn@gmail.com"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"singleQuote":true,"trailingComma":"none","bracketSpacing":false},"repository":{"url":"git+https://github.com/unicorn-utterances/rehype-slug-custom-id.git","type":"git"},"_npmVersion":"8.1.2","description":"plugin to add `id` attributes to headings similar to gatsby-remark-autolink-headers ","directories":{},"sideEffects":false,"_nodeVersion":"16.13.1","dependencies":{"lodash":"^4.17.21","unified":"^10.0.0","@types/hast":"^2.0.0","github-slugger":"^1.1.1","unist-util-visit":"^4.0.0","hast-util-to-string":"^2.0.0","hast-util-has-property":"^2.0.0","hast-util-heading-rank":"^2.0.0"},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"detail":true,"strict":true,"atLeast":90,"ignoreCatch":true},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.0.0","xo":"^0.44.0","tape":"^5.0.0","rehype":"^12.0.0","rimraf":"^3.0.0","prettier":"^2.0.0","remark-cli":"^10.0.0","typescript":"^4.0.0","@types/tape":"^4.0.0","@types/lodash":"^4.14.177","type-coverage":"^2.0.0","remark-preset-wooorm":"^9.0.0","@types/github-slugger":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rehype-slug-custom-id_1.1.0_1646973434239_0.034829789250666376","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"rehype-slug-custom-id","version":"2.0.0","description":"plugin to add `id` attributes to headings similar to gatsby-remark-autolink-headers ","license":"MIT","keywords":["unified","rehype","rehype-plugin","plugin","html","heading","slug","id"],"repository":{"type":"git","url":"git+https://github.com/unicorn-utterances/rehype-slug-custom-id.git"},"bugs":{"url":"https://github.com/unicorn-utterances/rehype-slug-custom-id/issues"},"sideEffects":false,"type":"module","types":"index.d.ts","main":"index.js","dependencies":{"@types/hast":"^3.0.4","github-slugger":"^2.0.0","hast-util-has-property":"^3.0.0","hast-util-heading-rank":"^3.0.0","hast-util-to-string":"^3.0.0","lodash":"^4.17.21","unified":"^11.0.5","unist-util-visit":"^5.0.0"},"devDependencies":{"@types/lodash":"^4.14.177","@types/tape":"^5.6.4","c8":"^10.1.2","prettier":"^3.3.2","rehype":"^13.0.1","remark-cli":"^12.0.1","remark-preset-wooorm":"^10.0.0","rimraf":"^5.0.7","tape":"^5.0.0","type-coverage":"^2.0.0","typescript":"^5.5.2","xo":"^0.58.0"},"scripts":{"build":"rimraf --glob \"*.d.ts\" && tsc && type-coverage","format":"remark . -qo && prettier . -w --loglevel warn && xo --fix","test-api":"node --conditions development test.js","test-coverage":"c8 --check-coverage --branches 80 --functions 90 --lines 90 --statements 90 --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,"rules":{"unicorn/prefer-at":"off"}},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"atLeast":90,"detail":true,"strict":true,"ignoreCatch":true},"_id":"rehype-slug-custom-id@2.0.0","gitHead":"2bff5c1b282dcbd3404658072647d30d1b7dcec4","homepage":"https://github.com/unicorn-utterances/rehype-slug-custom-id#readme","_nodeVersion":"18.20.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-3ED9HjExIZrC6WiC6V/9SnSuvGMdDb3dYM0WqSpIrLZDdEuSYlkr3iPp43urbgl7xz0Qy/7ZVj64sZbCr046bw==","shasum":"3f511a937de35c8dd6b356130b406d8e4cb19cfb","tarball":"https://registry.npmjs.org/rehype-slug-custom-id/-/rehype-slug-custom-id-2.0.0.tgz","fileCount":5,"unpackedSize":10229,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIES3DN0FD0Wiu8flis+JsO8C7YJggn24pPnBTZVQlutoAiAz8+ILblb9H2VeQzOPX6F4MY1P9DGqH1dIlYFxWf3spA=="}]},"_npmUser":{"name":"crutchcorn","email":"crutchcorn@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rehype-slug-custom-id_2.0.0_1719241462551_0.35052194825460536"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-10T22:05:13.964Z","modified":"2024-06-24T15:04:22.850Z","1.0.0":"2022-03-10T22:05:14.142Z","1.1.0":"2022-03-11T04:37:14.413Z","2.0.0":"2024-06-24T15:04:22.699Z"},"maintainers":[{"name":"crutchcorn","email":"crutchcorn@gmail.com"}],"repository":{"type":"git","url":"git+https://github.com/unicorn-utterances/rehype-slug-custom-id.git"},"keywords":["unified","rehype","rehype-plugin","plugin","html","heading","slug","id"],"license":"MIT","homepage":"https://github.com/unicorn-utterances/rehype-slug-custom-id#readme","bugs":{"url":"https://github.com/unicorn-utterances/rehype-slug-custom-id/issues"},"readme":"# rehype-slug-custom-id\n\n[![Build][build-badge]][build]\r\n[![Coverage][coverage-badge]][coverage]\r\n[![Downloads][downloads-badge]][downloads]\r\n[![Size][size-badge]][size]\n\n[**rehype**][rehype] plugin to add `id`s to headings with the option for custom IDs.\n\n## Install\n\nThis package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):\r\nNode 12+ is needed to use it and it must be `import`ed instead of `require`d.\n\n[npm][]:\n\n```sh\nnpm install rehype-slug-custom-id\n```\n\n## Use\n\nSay we have the following file, `fragment.html`:\n\n```html\n<h1>Lorem ipsum 😪</h1>\r\n<h2>dolor—sit—amet</h2>\r\n<h3>consectetur &amp; adipisicing</h3>\r\n<h4>elit</h4>\r\n<h5>elit</h5>\r\n<h6>Custom ID Should Be Here {#custom-id}</h6>\n```\n\nAnd our script, `example.js`, looks as follows:\n\n```js\nimport fs from 'node:fs'\r\nimport {rehype} from 'rehype'\r\nimport slug from 'rehype-slug'\r\n\r\nconst buf = fs.readFileSync('fragment.html')\r\n\r\nrehype()\r\n  .data('settings', {fragment: true})\r\n  .use(slug)\r\n  .process(buf)\r\n  .then((file) => {\r\n    console.log(String(file))\r\n  })\n```\n\nNow, running `node example` yields:\n\n```html\n<h1 id=\"lorem-ipsum-\">Lorem ipsum 😪</h1>\r\n<h2 id=\"dolorsitamet\">dolor—sit—amet</h2>\r\n<h3 id=\"consectetur--adipisicing\">consectetur &#x26; adipisicing</h3>\r\n<h4 id=\"elit\">elit</h4>\r\n<h5 id=\"elit-1\">elit</h5>\r\n<h6 id=\"custom-id\">Custom ID Should Be Here</h6>\n```\n\n## API\n\nThe default export is `rehypeSlug`.\n\n### `unified().use(rehypeSlug)`\n\nAdd `id` properties to h1-h6 headings that don’t already have one.\n\nUses [**github-slugger**][ghslug] to create GitHub style `id`s, or a custom ID if supplied like so:\n\n```html\n<h1>ID {#custom-id-here}</h1>\n```\n\nWe support the following options for the plugin:\n\n* `enableCustomId`: `Boolean`. Enable custom header IDs with {#id} (optional)\n* `maintainCase`: `Boolean`. Maintains the case for markdown header (optional)\n* `removeAccents`: `Boolean`. Remove accents from generated headings IDs (optional)\n\n## Security\n\nUse of `rehype-slug` can open you up to a [cross-site scripting (XSS)][xss]\r\nattack as it sets `id` attributes on headings.\r\nIn a browser, elements are retrievable by `id` with JavaScript and CSS.\r\nIf a user injects a heading that slugs to an `id` you are already using,\r\nthe user content may impersonate the website.\n\nAlways be wary with user input and use [`rehype-sanitize`][sanitize].\n\n## Related\n\n* [`rehype-slug`](https://github.com/rehypejs/rehype-slug)\r\n  — Add slugs to headings in html\n* [`remark-slug`](https://github.com/wooorm/remark-slug)\r\n  — Add slugs to headings in markdown\n* [`gatsby-remark-autolink-headers`](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-autolink-headers)\r\n  — Add slugs to headings in markdown for Gatsby\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/unicorn-utterances/rehype-slug-custom-id/workflows/main/badge.svg\n\n[build]: https://github.com/unicorn-utterances/rehype-slug-custom-id/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/unicorn-utterances/rehype-slug-custom-id.svg\n\n[coverage]: https://codecov.io/github/unicorn-utterances/rehype-slug-custom-id\n\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-slug-custom-id.svg\n\n[downloads]: https://www.npmjs.com/package/rehype-slug-custom-id\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-slug-custom-id.svg\n\n[size]: https://bundlephobia.com/result?p=rehype-slug-custom-id\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[license]: license\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[ghslug]: https://github.com/Flet/github-slugger\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[sanitize]: https://github.com/rehypejs/rehype-sanitize\n","readmeFilename":"readme.md"}