How do I escape three backticks surrounded by a codeblock in markdown?

In addition to nesting a fenced block inside an indented block (as demonstrated in another answer), you can also nest one fenced block inside another fenced block by using a different number of backticks (as you have tried). However, you must keep each set of deliminators on a separate line. And most implementations require three or more backticks (your use of 2 is another failure point). For example, notice that in the following example the outer block uses four backticks whereas the inner block uses three backticks:

````
```
UIBarButtonItem *search = [[UIBarButtonItem alloc]
```
````

In many implementations that will render as:

```
UIBarButtonItem *search = [[UIBarButtonItem alloc]
```

You may find this is not supported properly with some implementations however.

As an alternative, if the implementation you are using also supports tildes (~) as fenced code block deliminators, you can use those instead:

~~~
```
UIBarButtonItem *search = [[UIBarButtonItem alloc]
```
~~~

Again, never use less that three deliminator characters in a group and always include each group on a separate line by itself.

Leave a Comment