trentm/python-markdown2

Multiple fenced code blocks break them

IncandescentChrysalis opened this issue · 0 comments

Describe the bug

Multiple fenced code blocks seem to pollute each other

To Reproduce

* List 1
  ```
  code 1

  code 2
  ```

```
code 3
```

Observed behavior

<ul>
<li>List 1
<pre><code>code 1

code 2</li>
</ul>

</code></pre>

<pre><code>code 3

<p></code></pre></p>

Expected behavior

<ul>
<li>List 1
<pre><code>code 1

code 2
</code></pre></li>
</ul>
<pre><code>code 3</code></pre>

Debug info

Version of library being used:

  • markdown2==2.4.13

Extras used:

  • fenced-code-blocks

Additional context

Broken for nested lists too.

The following Markdown code:

* List 1
    * List 2
      ```
      code 1

      code 2
      ```

```
code 3
```

yields:

<ul>
<li>List 1
<ul>
<li>List 2
<pre><code>code 1

code 2</li>
</ul></li>
</ul>

</code></pre>

<pre><code>code 3

<p></code></pre></p>

instead of:

<li>List 1
<ul>
<li>List 2
<pre><code>code 1

code 2
</code></pre></li>
</ul></li>
</ul>
<pre><code>code 3</code></pre>

All Markdown code cross-tested with the markdown-it demo.