russross / blackfriday

Blackfriday: a markdown processor for Go
Other
5.42k stars 598 forks source link

List rendering #563

Open IanMadd opened 5 years ago

IanMadd commented 5 years ago

I'm getting odd behavior in lists:

Adding Paragraph to a list item:

*   This is a list item with two paragraphs.

    This is the second paragraph in the list item. 

*   Another item in the same list.

Output:

<ul>
<li><p>This is a list item with two paragraphs.</p>

<p>This is the second paragraph in the list item.</p></li>

<li><p>Another item in the same list.</p></li>
</ul>
Screen Shot 2019-08-28 at 11 02 37 AM

I think the proper output is:

<ul>
<li>This is a list item with two paragraphs.

<p>This is the second paragraph in the list item.</p></li>

<li>Another item in the same list.</li>
</ul>

Nested List Items:

- text goes here

      -   subitem text 
      -   subitem text

- text goes here

Output:

<ul>
<li><p>text goes here</p>
<ul>
<li>subitem text</li>
<li>subitem text</li>
</ul></li>
<li><p>text goes here</p></li>
</ul>
Screen Shot 2019-08-28 at 11 24 47 AM

Expected output:

<ul>
<li>text goes here

<ul>
<li>subitem text</li>
<li>subitem text</li>
</ul></li>

<li>text goes here</li>
</ul>
88250 commented 4 years ago

Adding <p> in a list indicates the list is a loose list. This rule defined in CommonMark spec, but blackfriday is not compliant to the spec fully, so the output may right to it.

I suggest you use a markdown processor compliant to CommonMark spec, I wrote one here 😄