Depending on which implementation you use, there may be a few options to chose from.
Use more than three backticks.
The rules for fenced code blocks do not strictly require the use of three backticks. Rather, it is three or more. The important thing is that the opening and closing deliminators each contain the same number of backticks. Any sets of backticks between the deliminators may contain a different number of backticks (usually less as some implementations are buggy). Like this:
# Markdown example
````
here is an example code.
```
// this area is nested 3-backticks code block.
const hello = "hello";
```
````
Note that the opening and closing deliminators each contain four backticks, while the three-backtick string within the code block is preserved.
Use tildes
Fenced code blocks were originally designed with tildes (~
) rather than backticks. The first few implementations only supported using three or more tildes as deliminators. A short time later, GitHub introduced fenced code blocks with backticks. After a bug report was filed, they added tilde support and now most implementations of fenced code blocks support both characters. Again, the key is that the same sequence of characters are used for both the opening and closing deliminators. Like this:
# Markdown example
~~~
here is an example code.
```
// this area is nested 3-backticks code block.
const hello = "hello";
```
~~~
Note that the fenced code block uses three tildes (~~~
), while the nested block of three backticks is preserved.
Escaping may not work.
Some people would first try using character escaping (backslash precedes the escaped character). However, generally escaping is ignored within code blocks. Otherwise, how would you be able to demonstrate how to do escaping within code blocks. Of course, different implementations may act differently with some of these details so YMMV.