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

Fence code blocks rendering bug #204

Open
prologic opened this issue Oct 16, 2021 · 6 comments
Open

Fence code blocks rendering bug #204

prologic opened this issue Oct 16, 2021 · 6 comments

Comments

@prologic
Copy link

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

@prologic
Copy link
Author

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:]]|$)

@prologic
Copy link
Author

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.

@kjk
Copy link
Contributor

kjk commented Oct 16, 2021

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?

@prologic
Copy link
Author

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>&rdquo;`</p>\n\n<h1>This one works for &ldquo;<code>code</code>, but that&rsquo;s about it.</h1>\n\n<p>(^|[[:space:][:punct:]])`[^`]+`([[:space:][:punct:]]|$)<br>\n&rdquo;</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 😂

@kjk
Copy link
Contributor

kjk commented Oct 17, 2021

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.

@prologic
Copy link
Author

I'll dig a bit further and get back to you 👌

@miekg miekg added question Further information is requested and removed question Further information is requested labels Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants