Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I escape 3-backticks code block in 3-backticks code block?

Tags:

markdown

I tried to put 3-backticks code block(```) in 3-backticks code block. but I could not get a correct result.

How can I escape that in 3-backticks code block?

Original markdown file:

# Markdown example

```
here is an example code.

```
// this area is nested 3-backticks code block.
const hello = "hello";
```

```

Expected result:

Markdown example

here is an example code.

```
// this area is nested 3-backticks code block.
const hello = "hello";
```
like image 744
mitsuruog Avatar asked Mar 14 '18 00:03

mitsuruog


People also ask

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.

How do you escape Backticks in markdown?

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

What is Backticks in discord?

1) Discord also supports code blocks as well. You can make your own code blocks by wrapping your text in backticks (`) 2) You can also use three backticks (```) to create multiline code blocks, like this beautifully written haiku.

How do you markdown a code block?

To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab. For example, given this input: This is a normal paragraph: This is a code block. A code block continues until it reaches a line that is not indented (or the end of the article).

How to escape and show Triple backtick(`) within code block?

This is a backtick or code block. To escape and show backtick (`) use backslash backtick (\`). To escape and show triple backtick (```) within code block, use (````) to replace (```). Single backtick (`) works within tripple backtick code block without needing special treatment.

How to escape backtick and triple backtick(`) in Markdown?

How To Escape Backtick And Triple Backtick (Code Block) In Markdown. This is a backtick or code block. To escape and show backtick(`) use backslash backtick (`). To escape and show triple backtick(```) within code block, use (````) to replace (```). Single backtick(`) works within tripple backtick code block without needing special treatment.

How to wrap inline code with triple or higher backticks?

– asmeurer Jun 16 '13 at 16:44 6 @asmeurer: Wrap your inline code with triple backticks. For triple or higher backticks, you can wrap your inline code with double backticks, rather than quadruple backticks (unless you need both triple and double backticks at different places).

How do you have two consecutive backticks in inline code?

9 3 How do you have two consecutive backticks in inline code? – asmeurer Jun 16 '13 at 16:44 6 @asmeurer: Wrap your inline code with triple backticks. For triple or higher backticks, you can wrap your inline code with double backticks, rather than quadruple backticks (unless you need both triple and double backticks at different places).


2 Answers

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.

like image 175
Waylan Avatar answered Sep 21 '22 14:09

Waylan


Have you tried:

# Markdown example

```
here is an example code.

\`\`\`
// this area is nested 3-backticks code block.
const hello = "hello";
\`\`\`

```

?

like image 40
EpicPandaForce Avatar answered Sep 21 '22 14:09

EpicPandaForce