6
\$\begingroup\$

When I want to list a few things and give a code example below each item how can I do it without writing anything between the list item and the code block?

Example:

  • List item

    Code example not formatted as code

  • List item

text

Code example formatted as code
\$\endgroup\$

1 Answer 1

14
\$\begingroup\$

Normally, code blocks are formatted using four spaces of indentation:

var string = 'string';
  • In a list, code blocks require eight spaces:

    var string = 'string';
    
  • After a list, a code block can be made using four spaces of indentation, but it needs to be after an intervening <!-- comment -->.

var string = 'string';
\$\endgroup\$
1
  • 1
    \$\begingroup\$ A rule of thumb for how many spaces you need is \$4(n + 1)\$ where \$n\$ is the level of nested lists. E.g. no lists is \$4(0 + 1)\$. \$\endgroup\$
    – Peilonrayz Mod
    Commented Feb 15, 2017 at 10:04

You must log in to answer this question.

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