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

Escape HTML entities in doc comments #10252

Merged
merged 2 commits into from
Jan 18, 2021
Merged

Conversation

oprypin
Copy link
Member

@oprypin oprypin commented Jan 14, 2021

The intention is to show their original form, but they get interpreted as HTML and the docs look weird/wrong:
https://crystal-lang.org/api/0.35.1/HTML.html#unescape(string:String):String-class-method

@Sija
Copy link
Contributor

Sija commented Jan 14, 2021

Shouldn't they be escaped by the doc generator instead?
Injecting html anywhere in the docs sounds like a bad idea.

@oprypin
Copy link
Member Author

oprypin commented Jan 14, 2021

Markdown natively has a fallback to HTML.
HTML entities are part of Markdown, you can use that on GitHub too.

© ©

Inside code tags, though, that is not the case, that is indeed a bug.

>>> import markdown
>>> m = markdown.Markdown()
>>> m.convert('''©''')
'<p>&copy;</p>'
>>> m.convert('''`&copy;`''')
'<p><code>&amp;copy;</code></p>'
>>> m.convert('''    &copy;''')
'<pre><code>&amp;copy;\n</code></pre>'

because then at least typical Markdown parsers agree with Crystal's parser.
@bcardiff bcardiff added this to the 0.36.0 milestone Jan 18, 2021
@bcardiff bcardiff merged commit f029f5e into crystal-lang:master Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants