Inconsistent and buggy lists separated by blank lines

Babelmark shows that lists separated by blank lines are treated inconsistently. Changing the number of blank lines between lists leads to even more inconsistent results.

Test cases

These are two basic test cases:

One blank line (should produce only one list, if I interpreted the spec correctly):

* aaa
* bbb

* ccc

Two blank lines (should produce two lists):

* aaa
* bbb


* ccc

Expected results

I was expecting the first test case to produce just one list and the second to produce the following:

<ul>
<li>aaa</li>
<li>bbb</li>
</ul>
<ul>
<li>ccc</li>
</ul>

The issue

Almost no implementation produces the expected result and most implementations produce weird artifacts (e.g. extra <p> elements).

Babelmark2 for one blank line

Babelmark2 for two blank lines

Some examples.

commonmark.js produces just one list, but with <li><p>aaa</p></li> items instead of the simpler <li>aaa</li> items that are produced when there are no blank lines.

pandoc produces a weird mix of <li></li> and <li><p></p></li>:

<ul>
    <li>foo</li>
    <li>
        <p>bar</p>
    </li>
    <li>
        <p>baz</p>
    </li>
</ul>

marked produces two different results. With one blank line it produces exactly what pandoc produces, while with two blank lines it produces the correct (or expected)

<ul>
    <li>foo</li>
    <li>bar</li>
</ul>
<ul>
    <li>baz</li>
</ul>

Are you looking at an older version of the spec?

Older versions had the “two blank lines ends a list”
rule, but this has been removed.

1 Like

As for the <p> elements: pandoc and marked don’t
claim to be commonmark compliant. Pandoc has a
different way of interpreting blank lines around list
items, described in its manual. The commonmark result
is consistent with the spec – see
https://spec.commonmark.org/0.28/#loose

1 Like