# How can I format a code block below a list?

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


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';

• 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)$. – Peilonrayz Feb 15 '17 at 10:04