diff --git a/bun.lockb b/bun.lockb new file mode 100644 index 0000000..833fb13 Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json index f442337..691cbdc 100644 --- a/package.json +++ b/package.json @@ -23,13 +23,13 @@ }, "devDependencies": { "@types/lodash.capitalize": "^4.2.9", - "@types/unist": "^2.0.6", - "mdast-util-to-string": "^3.1.1", + "@types/unist": "^2.0.10", + "mdast-util-to-string": "^4.0.0", "rehype-raw": "^6.1.1", - "rehype-stringify": "^9.0.3", - "remark-parse": "^10.0.1", + "rehype-stringify": "^9.0.4", + "remark-parse": "^10.0.2", "remark-rehype": "^10.1.0", - "typescript": "^5.0.2", + "typescript": "^5.5.4", "unified": "^10.1.2" } } diff --git a/src/index.ts b/src/index.ts index cfba6ff..655cf86 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import capitalize from "lodash.capitalize" import { visit } from "unist-util-visit" import { toHast } from "mdast-util-to-hast" import { toHtml } from "hast-util-to-html" +import { toString } from 'mdast-util-to-string'; import { FindAndReplaceList, findAndReplace as mdastFindReplace } from "mdast-util-find-and-replace" // !? -> optional embedding @@ -320,5 +321,13 @@ export default function ofm() { } } }) + + visit(tree, "heading", (node) => { + node.data = { + hProperties: { + id: toString(node) + } + }; + }); } }