9

Possible Duplicate:
How can the backtick character ` be included in code?

How do I do something like this:

`order`

But within a ``line`? <-- as you see over here I was able to get the starting backtick, but when I try to place on on the end,

it gets enclosed like this.

How do I get both backticks inline while still having the inline code block?

This is what happens when I try to escape the backticks with backslashes:
\this\

15
  • @TimPost -- These are not the same question. The one you call a duplicate is only asking about an ending backtick, I am asking about surrounding the word (or words) with backticks.
    – Naftali
    Jul 6, 2012 at 16:05
  • I re-opened, it may be worth noting that in your post.
    – user50049
    Jul 6, 2012 at 16:16
  • @TimPost Thank you :-D! I fixed the title, I don't how I can be more descript than that.
    – Naftali
    Jul 6, 2012 at 16:17
  • It's close, but I don't think duplicate. The title edit and this comment trail should suffice :) Sorry about that.
    – user50049
    Jul 6, 2012 at 16:18
  • Ah, but searching for "A single backtick in a code span" yields the nice How can the backtick character ` be included in code?, with a nice answer from Chris, which covers this too.
    – Arjan
    Jul 6, 2012 at 16:19
  • @Arjan ahhh, but if you notice in that post, none of the backticks are surrounding the code blocks.
    – Naftali
    Jul 6, 2012 at 16:19
  • 1
    Hehe, you're right! (Though it does quote the same Markdown help.)
    – Arjan
    Jul 6, 2012 at 16:20
  • Well gosh darnit this has to be a duplicate of something (I kid, I kid!) I'm pretty sure this hasn't come up before, but ICBW.
    – user50049
    Jul 6, 2012 at 16:24
  • @TimPost As could I. I see now that someone voted to close this as duplicate of the question Arjan linked....
    – Naftali
    Jul 6, 2012 at 16:25
  • 1
    Eh, I don't see why the post that Arjan linked to is insufficient. The second example from the Markdown help is exactly what this question is asking about.
    – Tim Stone
    Jul 6, 2012 at 16:25
  • @TimStone because as I said, that example has no surrounding backticks.
    – Naftali
    Jul 6, 2012 at 16:26
  • 1
    What is this, if not exactly what you're asking about? A backtick-delimited string in a code span: `` `foo` ``
    – Tim Stone
    Jul 6, 2012 at 16:28
  • @TimStone you see how that did not work in the comment?
    – Naftali
    Jul 6, 2012 at 16:28
  • 1
    Yes, because comment Markdown is different. Your post mentions comments a total of zero times. If you're interested, there's a detailed explanation of the differences.
    – Tim Stone
    Jul 6, 2012 at 16:31
  • Actually, reading Chris' answer again, it does mention it. (And it should, as it quotes the same thing I did. So, both @Tim's are right, I feel. I can add the note about comments to that answer, but I cannot delete my answer as long as it's accepter...
    – Arjan
    Jul 6, 2012 at 16:37

2 Answers 2

15

Use spaces:

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` ``

will produce:

<p>A single backtick in a code span: <code>`</code></p>

<p>A backtick-delimited string in a code span:  <code>`foo`</code></p>

Which on these sites indeed works just fine:

A single backtick in a code span: `

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

For comments:

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

12
  • Awesome. cool. I never knew it was a `` space `` issue....
    – Naftali
    Jul 6, 2012 at 16:02
  • Hmmm it does not seem to be working in the comments....
    – Naftali
    Jul 6, 2012 at 16:03
  • Indeed...
    – Arjan
    Jul 6, 2012 at 16:05
  • 2
    Ah, in comments one does need to escape using a backslash? `yes`.
    – Arjan
    Jul 6, 2012 at 16:07
  • Hmmm how did you do that? `This is a test` -- Cool ^_^
    – Naftali
    Jul 6, 2012 at 16:08
  • 2
    You might want to add the comment part to your answer.
    – Naftali
    Jul 6, 2012 at 16:08
  • Well, that was easier said than done ;-)
    – Arjan
    Jul 6, 2012 at 16:13
  • ` test ` `` test `` -- this doesn't seem to be working... <code>test</code> Lies, all of it!
    – Jason C
    Aug 8, 2013 at 18:09
  • 1
    `Works for me`, @Jason. That is: `\`Works for me\``.
    – Arjan
    Aug 8, 2013 at 18:15
  • `backslashes` -- perfect, got it. Thanks! I was confusing posts and comments and backslashes and double backticks and code tags and... well, it's working.
    – Jason C
    Aug 8, 2013 at 18:17
  • a=`echo "hello world"` - thanks - backslashes are what I'm looking for - upvoting this answer now Oct 8, 2013 at 21:52
  • how to make {r} this piece of code display in monocode mode? I am trying to write a Rmarkdown file to explain how the knitr package works to complie r code in the document. To just display {r}, ``` {r} works. However, it is not in the monocode mode but plain text
    – KevinKim
    Jan 23, 2017 at 21:36
2

Use the backslash, it escapes everything: `this`.

This is part of the official MarkDown spec; see Backslash escapes.

If you want to use a backtick inside an inline code block, use <code> tags, in combination with the escape: `backtick` (source: <code>`backtick`</code>).

4
  • Yes, but then the this is not inside the code block anymore.
    – Naftali
    Jul 6, 2012 at 15:52
  • Updated to use <code> tags. Jul 6, 2012 at 16:06
  • Ahhh, but your <code> idea won't work in comments.
    – Naftali
    Jul 6, 2012 at 16:18
  • Ahhh, but you didn't say it had to work in comments; backticks in comments are inside backticks do work with escapes (as you mentioned). Jul 6, 2012 at 16:49

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