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

Html special characters inside text links #7346

Closed
finex opened this issue Jun 1, 2020 · 10 comments
Closed

Html special characters inside text links #7346

finex opened this issue Jun 1, 2020 · 10 comments

Comments

@finex
Copy link

finex commented Jun 1, 2020

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

$ hugo version
v0.71.1

Does this issue reproduce with the latest release?

Yes

Current behaviour:

Hi, currently if you put special characters or html entities, the result is not predictable. Here you can find some examples: in some cases both the char and the html code are escaped, in other cases (like ... and ' or ' are rendered.

Markdown HTML output
[&](url) <a href="url">&amp;amp;</a>
[&amp;](url) <a href="url">&amp;amp;</a>
[...](url) <a href="url">&amp;hellip;</a>
[&hellip;](url) <a href="url">…</a>
[&nbsp;](url) <a href="url">&nbsp;</a>
[<](url) <a href="url">&amp;lt;</a>
[&lt;](url) <a href="url">&amp;lt;</a>
["](url) <a href="url">&amp;quot;</a>
[&quot;](url) <a href="url">&amp;quot;</a>
['](url) <a href="url">'</a>
[&apos;](url) <a href="url">'</a>

Expected behaviour

Special characters should be correctly rendered. At least one of the two versions (the html entity or the character itself).

Thanks :-)

@jmooring
Copy link
Member

jmooring commented Jun 4, 2020

I am unable to reproduce the problem with Hugo Static Site Generator v0.72.0/extended linux/amd64 BuildDate: 2020-05-31T18:10:04Z

@bep bep added this to the v0.73 milestone Jun 4, 2020
@hawkeye116477

This comment has been minimized.

@jmooring
Copy link
Member

jmooring commented Jun 4, 2020

I am still unable to reproduce the problem. Are you using a render hook to rewrite the link? If so, please point me to the code for your render hook.

@hawkeye116477
Copy link

hawkeye116477 commented Jun 4, 2020

Are you using a render hook to rewrite the link?

Ah, yes, sorry, my bad, I forgot about it, now is fine 😄

@jmooring
Copy link
Member

jmooring commented Jun 4, 2020

@hawkeye116477:

Please close this issue. In the future, please post problems such as these to the Hugo Forum.

@hawkeye116477
Copy link

hawkeye116477 commented Jun 4, 2020

@jmooring Ok, anyway, I didn't opened issue, @finex did that.

@finex
Copy link
Author

finex commented Jun 5, 2020

Hi, I simply installed Hugo 0.71 and created a markdown file with the code I've described on the first post. The Hugo settings are the default except for the "unsafe" setting. I will try again with 0.72 on the next days. 😀

@jmooring
Copy link
Member

jmooring commented Jun 5, 2020

I changed config.toml as shown below, and still cannot reproduce the problem.

[markup.goldmark.renderer]
unsafe = true

@finex
Copy link
Author

finex commented Jun 5, 2020

Are you using a render hook to rewrite the link? If so, please point me to the code for your render hook.

You're right: I've wrote a custom render template for adding target="_blank" on external links but the text was printed using {{ .Text }}. I've solved adding | safeHTML filter.

@github-actions
Copy link

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 Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants