Markdown-it plug-in unifies creation of TOC and heading id values, supports id uniqueness and referential integrity
npm install markdown-it-id-and-tocid attributes to use? Apparently, the id values may not match. So, why not choosing the one which generates it all consistently?
id values and identity of id values in headings and TOC
id prefixes
ul (default), ol or anything else
div element
npm install markdown-it-id-and-toc
`
Options
For detailed description, please see the plugin documentation.
This is just a self-explaining sample
`
enableHeadingId: true,
autoNumberingRegex: "^\\[\\]\\(\\=numbering([\\s\\S]*?)\\=\\)",
autoNumbering: {
"enable": false,
"pattern": [],
"defaultSuffix": ". ",
"defaultPrefix": "",
"defaultStart": 1,
"defaultSeparator": "."
},
includeLevel: [1, 2, 3, 4, 5, 6],
tocContainerClass: "toc",
tocRegex: "^\\[\\]\\(toc\\)",
excludeFromTocRegex: "\\[\\]\\(notoc\\)",
defaultListElement: "ul",
listElements: ["ul", "ul", "ul", "ul", "ul", "ul"],
defaultListElementAttributeSet: { style: "list-style-type: none;" },
listElementAttributeSets: [],
idPrefix: "headings."
`
Example of auto-numbering options defined as a first paragraph in the document:
`
[](=numbering {
enable: true
defaultSuffix: 1". "
h2.prefix: "Chapter "
h2.start: ["One", "Two", "Three", "Four"]
h2.suffix: ": "
h5.standAlong: true
h4.standAlong: true
h5.start: "a"
h5.suffix: ") "
}=)
``