Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

markdown

hexo

First, I'd like to say that I've read some recommended questions that may seem to answer my question, but they're all about escape single backtick in markdown. I've tried but none of them seem to work.

Here's what I've tried.

1.Double backtick - single space - three backticks.

To avoid any problems, I use image to discribe.

and it seems to be good in my markdown editor except missing the breakline. But bad luck, it seems terrible on hexo blog.

Then I test in Github for luck. And, difference shows. Shown in github.

2.Use backslash.

Unfortunatly, it shows dirrectly instead of escape the backtick.

Now, my question is, it works well here in sof, but not in my blog. What else I should try except using html tag, or is it the only way I should go? Is it the issue with my usage or my blog theme? Thanks in advance.

like image 448
Calios Avatar asked Aug 05 '15 06:08

Calios


People also ask

How do you escape code block in Markdown?

The bottom line is that ~~~ and ```` allow you to escape markdown code blocks for up to 2 nested levels - one for each of those escape sequences!

How do you escape Backticks in Markdown?

To include a non-code formatted backtick it can be added by escaping it with a \ .

How do you escape Backticks in discord?

As mentioned in the other answers to the question, you can simply escape backticks with a backslash `\` for inline formatting. Extra spacing also required if you want a backtick at the start of your quote.


2 Answers

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.

like image 127
Waylan Avatar answered Oct 24 '22 06:10

Waylan


There are two ways to represent code blocks in most Markdown implementations:

  • indent the whole block by four characters or one tab, as in the original implementation, and
  • use fenced code blocks, as in GitHub Flavored Markdown.

You can combine these techniques, causing the triple backticks from your fenced block to be treated part of the indented code block, e.g.

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

This snippet renders like this on Stack Overflow:

```
UIBarButtonItem *search = [[UIBarButtonItem alloc]
```
like image 5
Chris Avatar answered Oct 24 '22 08:10

Chris