gomarkdown / markdown

markdown parser and HTML renderer for Go
Other
1.36k stars 171 forks source link

Empty line in unordered list makes all list items wrapped in paragraph #310

Open flof opened 1 month ago

flof commented 1 month ago

Given this markdown:

- Item 1
- Item 2
- Item 3
- Item 4

If i convert this to HTML with the mdtohtml binary, the output is correctly:

<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>

But if i add an empty line to the list items, like this:

- Item 1
- Item 2

- Item 3
- Item 4

... all list items in the output are wrapped in <p> elements:

<ul>
<li><p>Item 1</p></li>

<li><p>Item 2</p></li>

<li><p>Item 3</p></li>

<li><p>Item 4</p></li>
</ul>

The additional paragraph element makes the rendered list ugly, because the list item bullet is not in the same line as the list item text.

I would expect, that the empty line is ignored or that a new <ul> is started.

Tested with github.com/gomarkdown/markdown v0.0.0-20230922112808-5421fefb8386. It is reproducible in the mdtohtml binary and in the library.