Some lists are not rendered as expected

AI-generated summary

The discussion Some lists are not rendered as expected revolves around the rendering of lists in Markdown. Sujan initially reported an issue with lists being rendered as separate lists when they should be combined. However, jomaxro clarified that the rendering is actually correct according to Markdown rules, with the space between lists causing them to be treated as separate.

Sujan then explained their desired outcome, where lists with no separator would be combined, and single-item lists would be separated. jomaxro pointed out that this is not how Commonmark works, and Sujan acknowledged this, referencing the Commonmark spec. The only solution found was to use an HTML line break (<br>) between lists to achieve the desired rendering.

  • 1

  • 2

  • 3

vs.

  • a
  • b

foo

  • c

123 is rendered as 3 individual lists, abc as 2 lists.

(Although this might also be a Markdown “feature”, please close if this is the case)

123 is rendered as one unordered list, just with spacing. ab and c are two lists, as you added a non-list element.

Here’s your markdown:

- 1
- 2

- 3

vs.

- a
- b

foo

- c

Note the raw HTML:

<div class="cooked">
    <ul>
        <li>
            <p>1</p>
        </li>
        <li>
            <p>2</p>
        </li>
        <li>
            <p>3</p>
        </li>
    </ul>
    <p>vs.</p>
    <ul>
        <li>a</li>
        <li>b</li>
    </ul>
    <p>foo</p>
    <ul>
        <li>c</li>
    </ul>
</div>

So everything appears to be working as I’d expect. What did you expect to happen?

To 1 and 2 not having any spacing, optionally also for 3 to be in its own list.

Basically:

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

That’s not how Commonmark works. You need something between the lists, not just a blank line.

You are right, this is really an eample in the spec:

What a …strange… thing.

The only solution for my problem seems to be this:

- foo
- bar
<br>
- baz
  • foo
  • bar

  • baz