Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected pandoc behavior converting markdown list to html

Tags:

pandoc

Pandoc describes its behavior clearly here in the section "Compact and loose lists"

However the conversion of

# Test

- Item 1

- Item 2
  - Subitem 1
  - Subitem 2

results in

<h1 id="test">Test</h1>
<ul>
<li><p>Item 1</p></li>
<li><p>Item 2</p>
<ul>
<li>Subitem 1</li>
<li>Subitem 2</li>
</ul></li>
</ul>

My understanding is that the output should be

<h1 id="test">Test</h1>
<ul>
<li><p>Item 1</p></li>
<li>Item 2
<ul>
<li>Subitem 1</li>
<li>Subitem 2</li>
</ul></li>
</ul>

I'm using pandoc 2.10.1. Any thoughts?

like image 466
Matthieu Avatar asked Feb 02 '26 19:02

Matthieu


1 Answers

This was changed in pandoc 2.7 in order to get pandoc's behavior more in line with that of CommonMark. The changelog contains this entry:

  • Markdown reader:

    • Improve tight/loose list handling (#5285). Previously the algorithm allowed list items with a mix of Para and Plain, which is never wanted.

The mentioned issue is #5285.

It seems that the documentation was not updated. This should be reported.

like image 66
tarleb Avatar answered Feb 04 '26 15:02

tarleb