Search code examples
markdowngithub-flavored-markdown

How do you write a literal backtick in the beginning of a markdown code block?


I know that to represent a literal backtick inside a code block, I could start with a "different number of backticks"

``foo ` bar``

This produces:

foo ` bar

However, what if I want my literal backtick to be the beginning of the code block? i.e:

```foo bar``

This does not work:

```foo bar``

If I add a space in the beginning, it will:

`foo bar

Is there a way I can achieve this without a space?


Solution

  • Add a space at the beginning and the end:

    `` `foo bar ``
    

    This renders as

    `foo bar

    both on Stack Overflow and GitHub.