What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 130 Stack Exchange communities.

I tried before to post a shell script that contained a ` character as an answer on Stack Overflow. The parser insisted on treating the backtick as formatting instead of part of code.

How can I include it?

share|improve this question

4 Answers 4

up vote 73 down vote accepted

If you do not want to use a pre-formatted block, there is still a way to do it inline.

From the “Code” section of the Markdown Documentation:

To include a literal backtick character within a code span, you can use multiple backticks as the opening and closing delimiters:

``There is a literal backtick (`) here.``

The above example renders like this (double quotes added): “There is a literal backtick (`) here.

Also of note, you can add spaces to render an inline code segment that starts with and/or ends with backticks:

The backtick delimiters surrounding a code span may include spaces — one after the opening, one before the closing. This allows you to place literal backtick characters at the beginning or end of a code span:

A single backtick in a code span: `` ` ``
A backtick-delimited string in a code span: `` `foo` ``

The above examples render like this (quotes added): “A single backtick in a code span: `” and “A backtick-delimited string in a code span: `foo`”.

This may be implementation specific, but it looks like you can use N backticks to delimit any inline sequence that does not itself contain a maximal subsequence of exactly N backticks. For example, you can use three backticks to delimit a sequence that does not contain triple backticks (single, double, quadruple, quintuple, etc. are okay though).

Three quoting one, two and four:  ``` one: `  two:   ``  four: ```` ```
Two quoting one, three, and four: ``  one: `  three: ``` four: ```` ``
One quoting two, three and four:  `   two: `` three: ``` four: ```` `


Three quoting one, two and four: one: ` two: `` four: ````
Two quoting one, three, and four: one: ` three: ``` four: ````
One quoting two, three and four: two: `` three: ``` four: ````

Finally, for comments:

Ah, in comments one does need to escape using a backslash? `\`yes\``.

share|improve this answer
Sometimes, at least, double ` work in comments. –  Mark Hurd Aug 1 '13 at 13:16
Ah, you're right @Mark, using a unique number of multiple opening and closing backticks works in comments too nowadays: ``one ` or three ``` within double backticks`` nicely yields one ` or three ``` within double backticks. But in comments, it still doesn't work when adding a space to the delimiters, to allow for a backtick at the start or end of the code. Like to get Perl's $` it seems one needs `$\`` in comments, as `` $` `` yields `` $` ``. –  Arjan Dec 22 '13 at 16:35
(Screenshot of the above comment, for future reference, as comments are rendered on the fly. So: if the implementation is changed, the above comment might render differently some day in the future.) –  Arjan Dec 22 '13 at 16:59
Uau, costed me a bit to the the gist of the thing, dam ticks :) –  brasofilo Oct 6 at 22:13

ChrisF's solution is the cleanest and easiest method, so I recommend using that whenever you can.

But if you find yourself needing it for inline code text and can tolerate needing to use the tags, it's HTML entity &#96;, demonstrated in <code> tags here: this ` is a backtick.

share|improve this answer
+1: This works every time unlike the accepted answer. –  Thomas Eding Mar 7 at 17:27

Put the code on a separate line and indent by 4 characters.

Like ` this
share|improve this answer

To show a single backtick formatted as inline code, there are two options:

`` ` ``

(note the spaces around the middle tick) or

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .