1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
x1 x3 x3 x1 x3 x3 x3 x12 x4 x3 |
// Imports
import type { Plugin } from "../renderer.ts"
import rehypeSlug from "rehype-slug"
import rehypeAutolinkHeadings from "rehype-autolink-headings"
/**
* Add anchors to headings and autolink them.
*
* @example
* ```md
* # foo
* ```
* ```html
* <h1 id="foo"><a href="#foo">foo</a></h1>
* ```
*/
export default {
rehype(processor) {
return processor.use(rehypeSlug).use(rehypeAutolinkHeadings, { behavior: "wrap" })
},
} as Plugin
|