8

I tried to end a code span with a backslash in a comment. It treated the ` as a literal. I tried to escape the backslash, but that didn't work either and it still treated the ` as a literal. See below and compare to the comment I will add:

Mary had a little\ lamb. It's fleece was white\\ as snow.

Raw source of that:

Mary had a `little\` lamb.
It's fleece was `white\\` as snow.
5
  • Mary had a little` lamb. It's fleece was white\` as snow.
    – Chloe
    Commented Aug 12, 2016 at 22:44
  • Mary had a little\` lamb. It's fleece was white\` as snow.
    – Chloe
    Commented Aug 12, 2016 at 22:45
  • BTW adding a space is a workaround: Mary had a little\ lamb. It's fleece was white\ as snow.
    – Chloe
    Commented Aug 12, 2016 at 22:46
  • 3
    Obviously the problem is that the phrase should use its, not it's ;) but let `try\`... Nope. You could try a zero width space, but I'm not sure i can create one on my mobile... Commented Aug 13, 2016 at 1:07
  • 2
    Mary had a little\ lamb. It's fleece was white\\ as snow. Commented Aug 13, 2016 at 8:26

1 Answer 1

12

I tried to escape the backslash, but that didn't work either and it still treated the ` as a literal.

You need to double the backticks:

Mary had a ``little\`` lamb. It's fleece was ``white\\`` as snow.

Results in:

The above is a screenshot of this comment.

2
  • I wonder what the commonmark spec says spec.commonmark.org
    – Braiam
    Commented Aug 13, 2016 at 14:16
  • @Braiam 1/ "Escaped characters are treated as regular characters and do not have their usual Markdown meanings" (where backslash is an escape character) and later 2/ "Backslash escapes are never needed, because one can always choose a string of n backtick characters as delimiters, where the code does not contain any strings of exactly n backtick characters. Code span backticks have higher precedence than any other inline constructs except HTML tags and autolinks.". To me that fits the observed behaviour. Commented Aug 13, 2016 at 14:25

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