-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
URL in title breaks ToC #7158
Comments
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
Still happens |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
Still happens |
Of course it still happens. It's because the concept of a "table of contents" does not support the concept of "links in headlines" because each item in a ToC is a link to a section and you can't have links within links. That is happening in other applications too. The silence in response to your issue is because it's impossible to add a system, that changes this behaviour. HTML could be stripped from the header, but then again formatting like bold or italic would disappear too. Move the link out of your headline and please stop removing the stale label. |
For starters, that's quite a hostile and toxic reply. Markdown supports links in headings just fine. That should not justify the ToC HTML breaking. I'd be fine with URLs being stripped from the ToC text and there's no reason why that should not work or be incompatible with other HTML in the headers. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
still happens |
I dug a bit in the Hugo source code, and the problem seems to be Line 56 in 0f01bd4
Which just takes the arbitrary HTML content of the title, but probably should sanitize it first. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
Still happens. |
|
For reference, @jmooring's POC shows the following: |
@thomwiggers This is not a cheap problem to solve. We'd need to parse the heading and walk the HTML nodes, using something like net/html, and remove all anchor elements but keep their inner HTML. Stripping all HTML tags is obviously not an option (e.g., markdown might be
|
Yeah, that makes sense, especially as doing it on the presumably-already-parsed Markdown level will probably not be sufficient (e.g. |
Steps to reproduce the behavior:
in a docs page with
toc=true
.What version of Hugo are you using (
hugo version
)?Result:
(Page source at https://github.com/thomwiggers/thomwiggers.nl/blob/new-site/content/teaching/hacking-in-c-2020/syllabus.md)
Does this issue reproduce with the latest release?
yes
(Originally reported at HugoBlox/hugo-blox-builder#1637)
The text was updated successfully, but these errors were encountered: