Skip to content

Multiple heading ids #2396

Closed
van-de-bugger opened this Issue · 3 comments

3 participants

@van-de-bugger

pandoc documentation says:

A header without an explicitly specified identifier will be automatically assigned a unique identifier based on the header text.

However, pandoc assigns an identifier even if identifier is already set, causing incorrect HTML output:

$ ~/.cabal/bin/pandoc --version
pandoc 1.15.0.6
Compiled with texmath 0.8.3, highlighting-kate 0.6.
...

$ cat input.md 
# Chapter 1 {id="ch01"}

text

$ ~/.cabal/bin/pandoc -f markdown -t html -o output.html input.md 

$ cat output.html 
<h1 id="chapter-1" id="ch01">Chapter 1</h1>
<p>text</p>

Note: h1 tag has two id attributes.

@jgm
Owner
@ousia

@van-de-bugger,

from this source:

# Chapter 1 {#ch1}
# Chapter 2 {id="ch2"}

you will have this HTML output (using latest stable pandoc):

<h1 id="ch1">Chapter 1</h1>
<h1 id="chapter-2" id="ch2">Chapter 2</h1>

Extended Markdown requires identifiers tagged as {#identifier} and classes as {.class}.

Just in case it might help.

@van-de-bugger

Thanks, I am aware about {#id} syntax, but I think {id="id"} is also valid.

@jgm jgm added a commit that closed this issue
@jgm Markdown reader: handle 'id' and 'class' in parsing key/value attrs.
    # Header {id="myid" class="foo bar"}

is now equivalent to

    # Header {#myid .foo .bar}

Closes #2396.
dcb0b02
@jgm jgm closed this in dcb0b02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.