Escaping inside code blocks?

John Gruber gruber at
Sat Dec 30 23:57:15 EST 2006

Andrea Censi <andrea at> wrote on 12/30/06 at 11:13 AM:

> Consider the input:

> ---

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


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


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

> ---


> The documentation says that line 2 and 3 are equivalent.

> (

Unless I'm forgetting something, the documentation is wrong. Or,
more specifically, it is outdated. The idea is that there are no
escapes in code spans. Just like with code blocks, the contents
are treated literally. That means the only character you have to
worry about escaping is ‘`’ itself, and instead of escaping it
with a backslash or something, the rule is just that you increase
the number of backticks used as the code span delimiters such that
if the contents of the code span contains N consecutive backticks,
you use N+1 backticks to delimit the span.

This way it's really easy to include snippets of code that already
contain backslashes.

> Question 1:

> How do you do escaping in code blocks in your implementation?

I don't.

> Question 2:

> How should I do escaping in my implementation?

You shouldn't.

> Question 2:

> What is the Markdown syntax for representing:

> 1) an inline code span whose string is "`" (only a backtick)

`` ` ``

> 2) an inline code span whose string is "\" (only a backslash)

> ?



More information about the Markdown-Discuss mailing list