Weird render when you have a trailing whitespace after triple backticks
pietroppeter opened this issue · 3 comments
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 "hello"
\```
</code></pre>
I would expect this:
<pre><code class="language-nim">echo "hello"
</code></pre>
which is what you get if you remove the trailing whitespace.
@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.
Thank you, will do!