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

Goldmark TOC is unescaped leading to invalid HTML output #6809

Closed
lukpank opened this issue Jan 26, 2020 · 1 comment · Fixed by #6934
Closed

Goldmark TOC is unescaped leading to invalid HTML output #6809

lukpank opened this issue Jan 26, 2020 · 1 comment · Fixed by #6934
Labels
Milestone

Comments

@lukpank
Copy link

lukpank commented Jan 26, 2020

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.63.1/extended linux/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

Yes

Invaild TOC HTML for goldmark

TOC entries are not properly escaped leading to invalid HTML for "goldmark" Markdown parser.

For the following Markdown heading

## A < B & C > D

the output TOC entry has the (not properly escaped) form

<li><a href="#a--b--c--d">A < B & C > D</a></li>

while the heading is properly escaped

<h2 id="a--b--c--d">A &lt; B &amp; C &gt; D</h2> 

For "blackFriday" markdown parser both TOC entry and the heading are
properly escaped.

satotake added a commit to satotake/hugo that referenced this issue Feb 22, 2020
Fixes gohugoio#6736
Fixes gohugoio#6809

Previously gordmark-based TOC renderes only `KindText` and `KindString`
This PR expands target node with goldmark's renderer

I am not sure of what are expected results as TOC contents in some (rare) cases
but Blackfriday's behaviours are fundamentally respected.
For example,
- image `[image text](link)` is rendered as `<img>` tag
- GFM AutoLink `gohugo.io` is rendered as text
@bep bep added this to the 0.65.3 milestone Feb 22, 2020
@bep bep closed this as completed in #6934 Feb 22, 2020
bep pushed a commit that referenced this issue Feb 22, 2020
Previously gordmark-based TOC renderes only `KindText` and `KindString`

This commit expands target node with Goldmark's renderer

I am not sure of what are expected results as TOC contents in some (rare) cases
but Blackfriday's behaviours are fundamentally respected.

For example,
- image `[image text](link)` is rendered as `<img>` tag
- GFM AutoLink `gohugo.io` is rendered as text

* Render AutoLink as <a> tag as Blackfriday does

Fixes #6736
Fixes #6809
@github-actions
Copy link

github-actions bot commented Feb 6, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants