Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fredrik-bakke opened this issue Oct 19, 2024 · 2 comments
Open

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

fredrik-bakke opened this issue Oct 19, 2024 · 2 comments
Labels
invalid This doesn't seem right question Further information is requested website

Comments

@fredrik-bakke
Copy link
Collaborator

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

@fredrik-bakke fredrik-bakke added bug Something isn't working question Further information is requested website labels Oct 19, 2024
@VojtechStep
Copy link
Collaborator

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 fredrik-bakke added invalid This doesn't seem right and removed bug Something isn't working labels Oct 20, 2024
@fredrik-bakke
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right question Further information is requested website
Projects
None yet
Development

No branches or pull requests

2 participants