forward slashes in <pre> tag in md

While working on a Advent of Code problem with ASCII graphics I came across a markdown parsing issue with forward slashes:

Leading empty lines and white space in a <pre> tag seem to confuse the md renderer while the html processor does not have a problem.

Also I did not expect that backslashes have to be escaped with another backslash in pre tags both in md and html tagged templates.

Perhaps this is a general markdown limitation.

1 Like

I recommend using fenced code blocks for preformatted text:

        G - H       J - K - L
       /           /
COM - B - C - D - E - F

Thanks for the workaround but I tend to forget the more exotic md decorators.

So <pre> tags are known to not always behave ?

And backslashes still need to be escaped in fenced code blocks ?

This appears to be a Marked issue so nothing observable related. Perhaps it is actually a more general md issue since this also does not work on commonmark
I could reproduce on


Yes, backslashes need to be escaped.

The behavior of Marked in regards to embedding HTML within Markdown is a bit… unpredictable. It’s a bit more predictable if you stick to Markdown or use ${…} to embed an html template literal within Markdown.