#937·parsedown

Unindented fenced code blocks inside lists prematurely terminate at the first blank line

Author: jameschertiCreated May 19, 2026Updated May 19, 2026

When a fenced code block with zero indentation immediately follows a list item without a preceding blank line, Parsedown treats the code block as part of the list item via lazy continuation. However, Parsedown incorrectly terminates the list item the moment it encounters a blank line inside the code block.

The portion of the code before the blank line is rendered as a <pre><code> block inside the <li>, while the portion after the blank line is kicked out of the list and incorrectly parsed as standard <p> paragraphs.

Environment:

  • Parsedown version: 1.8.0
  • PHP version: 8.5.6

Steps to Reproduce

Parse the following Markdown string:

1. List item here
```
line 1

line 2
```

Actual Behavior

The parser splits the code block at the blank line. line 1 remains in the list, while line 2 escapes the list and is parsed as a paragraph.

xml
<ol>
<li>List item here
<pre>
  <code class="language-elisp">line 1</code>
</pre>
</li>
</ol>

<p>line 2</p>

Expected Behavior

An unindented fenced code block should immediately interrupt the list and break out of it, rendering as a standalone code block at the document root.

If it is intended to be inside the list, it must be indented. Regardless of the interpretation, the fenced code block itself must remain intact and not be split into HTML paragraphs.