4.4Indented code blocks
An indented code block is composed of one or more indented chunks separated by blank lines. An indented chunk is a sequence of non-blank lines, each preceded by four or more spaces of indentation. The contents of the code block are the literal contents of the lines, including trailing line endings, minus four spaces of indentation. An indented code block has no info string.
An indented code block cannot interrupt a paragraph, so there must be a blank line between a paragraph and a following indented code block. (A blank line is not needed, however, between a code block and a following paragraph.)
If there is any ambiguity between an interpretation of indentation as a code block and as indicating that material belongs to a list item, the list item interpretation takes precedence:
The contents of a code block are literal text, and do not get parsed as Markdown:
Here we have three chunks separated by blank lines:
Any initial spaces or tabs beyond four spaces of indentation will be included in the content, even in interior blank lines:
An indented code block cannot interrupt a paragraph. (This allows hanging indents and the like.)
However, any non-blank line with fewer than four spaces of indentation ends the code block immediately. So a paragraph may occur immediately after indented code:
And indented code can occur immediately before and after other kinds of blocks:
# Heading
foo
Heading
------
foo
----
<h1>Heading</h1>
<pre><code>foo
</code></pre>
<h2>Heading</h2>
<pre><code>foo
</code></pre>
<hr />
The first line can be preceded by more than four spaces of indentation:
Blank lines preceding or following an indented code block are not included in it:
Trailing spaces or tabs are included in the code block’s content: