Open prologic opened 3 years ago
Example:
would you know the regex to use within .muttrc to colorise a Markdown code block like the one below?
# This one works for `code`, but that's about it.
(^|[[:space:][:punct:]])\`[^\`]+\`([[:space:][:punct:]]|$)
Hilariously it doesn't seem to render correctly with Github's own Markdown support in comments either π
Oh the above rendering worked just fine on Github, but falls over when you place the sample itself inside a code fence.
This is the html I get:
<p>would you know the regex to use within .muttrc to colorise a Markdown code block like the one below?</p>
<pre><code># This one works for `code`, but that's about it.
(^|[[:space:][:punct:]])\`[^\`]+\`([[:space:][:punct:]]|$)
</code></pre>
Which seems correct to me.
What do you get and what do you expect?
This is what I end up with:
DEBU[0051] md:
"would you know the regex to use within .muttrc to colorise a Markdown code block like the one below?\n\n```\n# This one works for ```code`, but that's about it.\n(^|[[:space:][:punct:]])\\`[^\\`]+\\`([[:space:][:punct:]]|$)\n``"
DEBU[0051] maybeUnsafeHTML:
"<p>would you know the regex to use within .muttrc to colorise a Markdown code block like the one below?</p>\n\n<p>”`</p>\n\n<h1>This one works for “<code>code</code>, but that’s about it.</h1>\n\n<p>(^|[[:space:][:punct:]])`[^`]+`([[:space:][:punct:]]|$)<br>\n”</p>\n"
DEBU[0051] html:
"<p>would you know the regex to use within .muttrc to colorise a Markdown code block like the one below?</p>\n\n<p>β`</p>\n\n<h1>This one works for β<code>code</code>, but thatβs about it.</h1>\n\n<p>(^|[[:space:][:punct:]])`[^`]+`([[:space:][:punct:]]|$)<br>\nβ</p>\n"
I'm not actually sure what's going on here just yet... I need to analyze this a bit. Something is going wrong in this process and it may not be your library's fault π
Here's the code to get the result I got: https://github.com/gomarkdown/markdown/blob/master/cmd/printast/main.go#L44
You might be pre-processing markdown before passing it to parser, postprocessing the html you get from the renderer or using different parser or renderer flags.
I'll dig a bit further and get back to you π
The following piece of Markdown does not render correctly:
Hilariously it doesn't seem to render correctly with Github's own Markdown support in comments either π foo.md