Heading identifiers
See also the auto_identifiers
extension above.
Headings can be assigned attributes using this syntax at the end of the line containing the heading text:
{#identifier .class .class key=value key=value}
Thus, for example, the following headings will all be assigned the identifier foo
:
# My heading {#foo}
## My heading ## {#foo}
My other heading {#foo}
---------------
(This syntax is compatible with PHP Markdown Extra.)
Note that although this syntax allows assignment of classes and key/value attributes, writers generally don’t use all of this information. Identifiers, classes, and key/value attributes are used in HTML and HTML-based formats such as EPUB and slidy. Identifiers are used for labels and link anchors in the LaTeX, ConTeXt, Textile, Jira markup, and AsciiDoc writers.
Headings with the class unnumbered
will not be numbered, even if --number-sections
is specified. A single hyphen (-
) in an attribute context is equivalent to .unnumbered
, and preferable in non-English documents. So,
# My heading {-}
is just the same as
# My heading {.unnumbered}
Pandoc behaves as if reference links have been defined for each heading. So, to link to a heading
# Heading identifiers in HTML
you can simply write
[Heading identifiers in HTML]
or
[Heading identifiers in HTML][]
or
[the section on heading identifiers][heading identifiers in
HTML]
instead of giving the identifier explicitly:
[Heading identifiers in HTML](#heading-identifiers-in-html)
If there are multiple headings with identical text, the corresponding reference will link to the first one only, and you will need to use explicit links to link to the others, as described above.
Like regular reference links, these references are case-insensitive.
Explicit link reference definitions always take priority over implicit heading references. So, in the following example, the link will point to bar
, not to #foo
:
# Foo
[foo]: bar
See [foo]