john c. j.
john c. j.

Reputation: 1185

Fenced code block inside another fenced code block

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?

Upvotes: 14

Views: 3335

Answers (1)

JojOatXGME
JojOatXGME

Reputation: 3296

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...

Upvotes: 23

Related Questions