Skip to content
Crozzers edited this page Dec 4, 2023 · 2 revisions

header-ids extra

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.

Extra options

This extra allows for the following configuration options:

  • mixed (bool, default False): 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, default True): reset the internal duplicate ID counter before converting new markdown snippets