7

I looked over https://meta.stackoverflow.com/editing-help#code but could not find what the Github-style code block markdown is used for on SE websites.

I see that they generate a <code> element but people say they are not code blocks. What are they then? (any documentation / help). What are they used for?

Example:

This is written between triple backquotes.

2
  • To my knowledge, the only difference (between 3 and one backtick) is that three backticks allow for inline backticks without a preceding backslash: This is with three: `. This is with one: `. Commented Jul 22, 2013 at 21:48
  • It's actually documented in the Help Center's "Editing Help" under "Code Spans" section, but it's not easy to find. You have to click "Code and Preformatted Text" to reveal that section Commented Jul 23, 2013 at 2:37

2 Answers 2

10

Three backquotes just resolves to one backquote which is for inline code formatting (as you say it generates <code> tags). IE:

`mmmmmmmm stuff`

and

```mmmmmmmmm stuff```

are identical.

Hello I have some code here that I'd like to put inline with some number of backticks.

Etc.

A code block, however, includes entire lines; ie, the mmmmmm stuff above could not have been shown (easily) within backtick-delimited inline code.

2
  • 4
    Who's playing with the voting again? Commented Jul 22, 2013 at 21:47
  • 5
    But you need multiple backticks if you want to include a backtick in the code itself, like: ``use `backticks` in code``.
    – Arjan
    Commented Jul 22, 2013 at 23:05
6

'Tis known by many names

  • code span
  • inline code span
  • inline code

Code blocks is formed when you indent a line by 4 spaces; inline code span is formed by enclosing text in a pair of backticks.

As documented in Help Center → Editing Help → Code Spans section:

If your code itself contains backticks, you may have to use multiple backticks as delimiters:

This is useful in some occasion where the inline code contains literal backticks (Perl and shell comes to mind, although I'm sure there are more).

  1. With the regular single backticks, this markdown

    `@files = `ls secret`;`
    

    would render as

    @files =ls secret;

    which is totally ugly (I just puked a little in my mouth).

  2. With multiple backticks, i.e.

    ``@files = `ls secret`;``
    

    or

    ```@files = `ls secret`;```
    

    you get

    @files = `ls secret`;

    which is totally hot and correct.

When your code doesn't contain backticks, having single, double, or triple backticks makes no difference.

You must log in to answer this question.

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