Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fenced code block inside another fenced code block

Tags:

markdown

I'm trying to write article about Markdown syntax, and to write it, I use Markdown.

So, my document looks like this:

Example of markdown code:

```
foo

```
fenced code block (fail)
```

bar
```

lalala...

And this breaks the parser. Screenshot taked from Commonmark dingus, but is also rendered in some another parsers I tried, namely Showdown and MultiMarkdown.

(Maybe such issues fixed in non-javascript parsers, like Kramdown? I doesn't tested)

enter image description here

How it may be fixed?

like image 951
john c. j. Avatar asked Feb 18 '17 19:02

john c. j.


1 Answers

I couldn't find it documented but you can increase the amount of backticks in commonmark.js dingus and GitHub Flavored Markdown. Your example could be fixed like this:

Example of markdown code:

`````
foo

```
fenced code block (fail)
```

bar
`````

lalala...

Be aware that it might not work on other parsers (like Showdown). However, some parsers do not support fanced code at all. Another possibility is to not use fenced code. You could write

Example of markdown code:

    foo

    ```
    fenced code block (fail)
    ```

    bar

lalala...
like image 156
JojOatXGME Avatar answered Sep 28 '22 16:09

JojOatXGME