UniMath / agda-unimath

The agda-unimath library
https://unimath.github.io/agda-unimath/
MIT License
222 stars 71 forks source link

Mdbook doesn't render links in headers in the right-hand bar #1204

Open fredrik-bakke opened 3 weeks ago

fredrik-bakke commented 3 weeks ago

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.

Screenshot 2024-10-19 at 20 15 58
VojtechStep commented 3 weeks ago

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

  1. 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
  2. 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 3 weeks ago

I see, thank you for clarifying! I'll leave this issue open until the problematic headers are fixed then.