Rendering of markdown lists depends on content

This is a bit of placeholder as I haven’t had a chance to check the Common mark spec, or create a test repo, but I have noticed the following behaviour:

TL;DR

Notice <li><p>text vs <li>text depending on the content

Discussion

The following markdown:

* To test this we need very long code lines that have words like antidisestablishmentarianism so that we can detect the failure to wrap the lines.
* As well as regular lines, for filler.

What happens if we have a paragraph in the middle?

* Another very long line of text, this time in a list following a paragraph
  * `And some long code blocks following in a sub-list`
  * `Like these ones, and on a real site, even more`

Results in the following HTML

<ul>
<li>To test this we need very long code lines that have words like antidisestablishmentarianism so that we can detect the failure to wrap the lines.</li>
<li>As well as regular lines, for filler.</li>
</ul>
<p>What happens if we have a paragraph in the middle?</p>
<ul>
<li>Another very long line of text, this time in a list following a paragraph
<ul>
<li><code>And some long code blocks following in a sub-list</code></li>
<li><code>Like these ones, and on a real site, even more</code></li>
</ul>
</li>
</ul>

and this markdown

* To test this we need very long code lines that have words like antidisestablishmentarianism so that we can detect the failure to wrap the lines.
* As well as regular lines, for filler.
* Another very long line of text, this time in a list without a paragraph on the page
  * `And some long code blocks following in a sub-list`
  * `Like these ones, and on a real site, even more`

generates

<ul>
<li>To test this we need very long code lines that have words like antidisestablishmentarianism so that we can detect the failure to wrap the lines.</li>
<li>As well as regular lines, for filler.</li>
<li>Another very long line of text, this time in a list without a paragraph on the page
<ul>
<li><code>And some long code blocks following in a sub-list</code></li>
<li><code>Like these ones, and on a real site, even more</code></li>
</ul>
</li>
</ul>

BUT

* To test this we need very long code lines that have words like antidisestablishmentaryanism so that we can detect the failure to wrap the lines.
* As well as regular lines, for filler.

* Like The C Shore (another former name of this site)
  * `http://www.cshorewellfleet.com`
  * `https://bythecshore.com`
  * ~~`https://www.cookerealty.com/ocean-isle-beach-rentals/c-shore-e-2nd`~~
  * `https://www.c-shore.com/`

generates

<ul>
<li>
<p>To test this we need very long code lines that have words like antidisestablishmentaryanism so that we can detect the failure to wrap the lines.</p>
</li>
<li>
<p>As well as regular lines, for filler.</p>
</li>
<li>
<p>Like The C Shore (another former name of this site)</p>
<ul>
<li><code>http://www.cshorewellfleet.com</code></li>
<li><code>https://bythecshore.com</code></li>
<li><del><code>https://www.cookerealty.com/ocean-isle-beach-rentals/c-shore-e-2nd</code></del></li>
<li><code>https://www.c-shore.com/</code></li>
</ul>
</li>
</ul>

Notice <li><p>text vs <li>text depending on the content

Question

Am I missing something, or is this a bug?

This is according to the Common mark spec, see loose list.

You can trigger it like this:

* aaa

* bbb
* ccc

It the empty line after the first item that does it.

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.