When special HTML comments used for snippets are present in a post, these comments break the rendering of the post. For example, consider the following markdown code (notice that the whole thing is indented 4 spaces so it should be rendered as code exactly the way it is, not as a snippet):
<!-- bеgin snippet: js hide: false --> <!-- language: lang-html --> some text <!-- end snippet -->
Note that I replaced the
begin with a Unicode version to get around the bug I'm posting this question about, so if you want to test it, you need to change it back. This will also be the case in several other parts of this post.
The above markdown code renders as following in the preview:
And as the following when the post is submitted:
While it should render as following:
<!-- bеgin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> some text <!-- end snippet -->
I also noticed that the numbers and letters inside the
<pre> tag in the preview are completely random. By simply deleting a character and adding the same character again, I got completely different numbers and letters (although the dashes stayed at the same positions).
After some testing, I noticed that this happens for every time there are these three comments in the code block, in this order:
A comment of the type
<!-- bеgin snippet: js hide: false -->, where the value of
js hidecan be
false, and possibly containing other parameters such as
At least one of the comments
<!-- language: lang-html -->,
<!-- language: lang-css -->or
<!-- language: lang-js -->.
<!-- end snippet -->comment.
If one or both of the
begin snippet or
end snippet comments is missing, everything renders normally. If the
language comment is missing or is before or the
begin snippet comment or after the
end snippet comment, everything is rendered normally except that the
begin snippet and
end snippet comments aren't rendered and there is an "edit the above snippet" link at the end of the code. For example the following code:
<!-- bеgin snippet: js hide: false --> some text <!-- end snippet -->
is rendered as this in the preview:
and as this in the submitted post (note that the comments are missing):
Also, there are similar problems when the snippet comments are in backticks. For example, my three bullet points earlier in this question have the following markdown code:
- A comment of the type `<!-- bеgin snippet: js hide: false -->`, where the value of `js hide` can be `true` or `false`, and possibly containing other parameters such as `console: true`. - At least one of the comments `<!-- language: lang-html -->`, `<!-- language: lang-css -->` or `<!-- language: lang-js -->`. - An `<!-- end snippet -->` comment.
If I wouldn't have used a Unicode trick, this would have been rendered as:
- A comment of the type `
`. - An `
` or `
I think that anything that is indented 4 spaces or within backticks should be treated as code, no matter if it would have a special meaning if it weren't formatted as code.
Can these bugs please be fixed?