Can’t nest a code block inside a code block, the render result is glitchy
The only real use case I could think of (also the situation I ran into) is in some markdown syntax tutorial where you want to show the code and render result side by side:
but theoretically speaking, in a code block anything should be treated as a part of the code, and should not interfere with the render result. For now, the only language I know that is using the triple backtick in the syntax is markdown, but it might be the case that:
someone might want a triple backtick in their comments or strings
some other languages may implement this in the future. for example, Golang already uses a pair of single backticks to mark a raw string, while Python uses triple quotation marks, so it would not be surprising. If some languages decide to use triple backtick as a part of normal syntax in the future, this would be really frustrating.
As far as I know, there is no standard for code block implementation in markdown. Currently, the only syntax required is a pair of triple backticks (in different lines), the former marks the start, and the latter marks the end. So by this grammar, there can’t be any triple backticks in between, which means there can’t be them in the code block.
But the user might want to include triple backticks in their rendering result, hence I propose some work around here:
Add a way to escape the triple backtick, for example, use slash before the backtick.
this should be rendered as normal triple backticks inside the code block, as in
markdown the render result is what really matters.
Allow the user to optionally mark the start and the end for the code block, in a way this is similar to how raw string is implemented in cpp
the above syntax is to optionally add a marker after the language code, and the
the renderer will treat everything as a part of the code block including triple backticks
until the comment contains the same marker. The last triple backtick is not included in
the render result.
for backward compatibility, the end mark could be on the next line of the
latter triple backticks, since currently if anything is on the same line it will be treated as
a start point and the render result will be wrong. Or maybe it’s not needed since the
current rendering is glitchy anyway and we just implement a working solution.
There could be other ways to implement this feature, the core idea here is to make it possible to include triple backticks in a glitchless rendering result.
don’t nest or tolerate the glitchy result
related to a bug report by me