-
Notifications
You must be signed in to change notification settings - Fork 435
header ids
Crozzers edited this page Dec 4, 2023
·
2 revisions
The header-ids
extra does not introduce any new Markdown syntax. Instead, it simply takes modifies the headings generated and gives them unique id
attributes. This allows you to link to section within a document using a fragment.
For instance, that this plain Markdown:
# The book of many colours
## Red
## Yellow
## Purple
## Purple
It will produce HTML like this:
<h1 id="the-book-of-many-colours">The book of many colours</h1>
<h2 id="red">Red</h2>
<h2 id="yellow">Yellow</h2>
<h2 id="purple">Purple</h2>
<h2 id="purple-2">Purple</h2>
You can then link to sections like this: http://example.com/document.html#the-book-of-many-colours
The IDs generated are ASCII with no special characters like spaces. A dash and a number are appended if necessary to keep the IDs unique.
This extra allows for the following configuration options:
-
mixed
(bool, defaultFalse
): enable parsing of pre-existing HTML header tags. Elements without IDs will have one generated and added. -
prefix
(string): prefix to be added to all generated header IDs -
reset-count
(bool, defaultTrue
): reset the internal duplicate ID counter before converting new markdown snippets