Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one escape backticks in markdown?

I am writing some documentation in markdown and I want to document how to create a text file using a bash HEREDOC. Here is the command I want to document:

# cat > /tmp/answers.txt <<EOT > value1=blah > value2=something else > value3=`hostname` > value4=onetwothree EOT 

In markdown one uses the ` to render the text as "code" I have tried doing this ...

`# cat > /tmp/answers.txt <<EOT` `> value1=blah` `> value2=something else` `> value3=\`hostname\`` `> value4=onetwothree` `EOT` 

... but that results in something that looks like this ...

# cat > /tmp/answers.txt <<EOT > value1=blah > value2=something else > value3=\ 

hostname
> value4=onetwothree
EOT

like image 624
Red Cricket Avatar asked Jun 19 '14 17:06

Red Cricket


People also ask

How do you escape a character in Markdown?

In Markdown, you can escape various characters using a backslash ( \ ), so if you wanted to type C#, you would use C\# .

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 stop a code block in Markdown?

To create a fenced code block that spans multiple lines of code, set the text inside three or more backquotes ( ``` ) or tildes ( ~~~ ). Open and close the block with the same character. Use the same number of characters to open and close the code fence.


2 Answers

The original Markdown syntax documentation covers this; it says that you have to use multiple backticks to bracket the code expression, so like this:

``here you go - ` this was a backtick`` 

renders like this:

here you go - ` this was a backtick

If you want to include a backtick in normal text, not in a code block, a backslash escape does the trick; for example this:

Here's a backtick: \`; then, here's another one: \` 

renders like this:

Here's a backtick: `; then, here's another one: `

(I tested this on commonmark and github and it behaves the same so it's not just a Stack Overflow oddity)

like image 192
Glyph Avatar answered Sep 21 '22 19:09

Glyph


This code block below does the trick.

``` # cat > /tmp/answers.txt <<EOT > value1=blah > value2=something else > value3=`hostname` > value4=onetwothree EOT ``` 

The three Backtick means it's snippet of code and a snippet must end with three more Backtick.

For more help with Markdown refer this CheatSheet.

like image 42
Adi Avatar answered Sep 17 '22 19:09

Adi