Mdbook doesn't render links in headers in the right-hand bar
fredrik-bakke opened this issue · 2 comments
fredrik-bakke commented
I'm guessing this is related to #658 and is a bug on the side of mdbook
. Still, I wanted to at least record it.
VojtechStep commented
It's not a bug in mdbook per se. Mdbook wraps the text of every heading in a link to itself, so the resulting HTML looks like <h2 id="xyz"><a class="heading" href="#xyz">Heading text</a></h2>
. The pagetoc is generated by iterating over all anchors with the heading
class and using their .text
attribute.
However, when you manually add a link to a heading, you
- prevent pagetoc from seeing the text, since now you have a nested link and pagetoc would need to look at
.children
instead of.text
, and - generate invalid HTML. Nested
a
tags are prohibited by the standard. That's the main problem IMO, and I'd refrain from adding links to section headings.
fredrik-bakke commented
I see, thank you for clarifying! I'll leave this issue open until the problematic headers are fixed then.