HeaderId

Summary

An extension to Python-Markdown that automatically generates 'id' attributes for HTML header elements (h1-h6) in markdown's output.

This extension is included in the standard Markdown library.

Syntax

By default, all headers will automatically have unique "id" attributes generated based upon the text of the header (See below to turn this off). Note this example in which all three headers would have the same "id":

#Header
#Header
#Header

Results in:

<h1 id="header">Header</h1>
<h1 id="header_1">Header</h1>
<h1 id="header_2">Header</h1>

Configuring the Output

The HeaderId extension has four configuration settings:

Using with Meta-Data

The HeaderId Extension also supports the Meta-Data Extension. Please see the documentation for that extension for specifics. The supported meta-data keywords are:

When used, the meta-data will override the settings provided through the
extension_configs interface.

This document:

header_level: 2
header_forceid: Off

# A Header

Will result in the following output:

<h2>A Header</h2>