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

Weird render when you have a trailing whitespace after triple backticks #64

Closed
pietroppeter opened this issue Feb 24, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@pietroppeter
Copy link
Sponsor Contributor

I am not even sure if this is a bug or it is according to specs (I know markdown is weird about trailing whitespaces).
Adding a trailing whitespace to a triple backtick makes markdown not recognize it that it ends the code block.

this (for clarity I am using a '*' char that I later replace to whitespace):

import markdown
import std / strutils

echo markdown("""
```nim
echo "hello"
```*
""".replace('*', ' '), config=initGfmConfig())

outputs this (without the backslash which I had to add for GitHub to render it):

<pre><code class="language-nim">echo &quot;hello&quot;
\```
</code></pre>

I would expect this:

<pre><code class="language-nim">echo &quot;hello&quot;
</code></pre>

which is what you get if you remove the trailing whitespace.

@soasme soasme added the bug Something isn't working label Feb 24, 2023
@soasme
Copy link
Owner

soasme commented Feb 24, 2023

@pietroppeter Thanks for bringing it up. I think it's a nim-markdown bug.

Here is my research:

Nim-markdown closing fence ends up with ```($|\n), which does not allow trailing whitespaces after backticks.

While the current CommonMark (v.0.30) spec allows it:

The closing code fence may be preceded by up to three spaces of indentation, and may be followed only by spaces or tabs, which are ignored.

I will make a bugfix PR for it.

@soasme
Copy link
Owner

soasme commented Feb 24, 2023

This issue is fixed in #65. Please upgrade to v0.8.7 to test it out. Thanks.

@pietroppeter
Copy link
Sponsor Contributor Author

Thank you, will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants