You've already forked remark-ofm
Add ID to headings
This commit is contained in:
@@ -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)
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user