List formatting breaks when there's an empty line separating them

AI-generated summary

The discussion addresses an issue with list formatting in Discourse when an empty line separates two lists, causing rendering problems. JP_ reports that mixing tight and loose list spacing in Markdown leads to formatting errors. codinghorror explains this is due to Markdown’s rules for list spacing, referencing Babelmark for testing. cpradio shares that CommonMark handles this better, while Mittineague suggests using <br> or a horizontal rule as workarounds, though these have limitations. elberet notes that some workarounds still result in a single unordered list. JP_ mentions that tools like Pandoc handle the issue correctly. sam states the issue is resolved with the new Markdown implementation.

I can’t get the raw text to display with </> formatting, so here (might need to open in new window or refresh to see source)

  • group A 1
  • group A 2
  • group A 3
  • group A 4
  • group A 5

When I try to have two lists separated by an empty line, it throws the whole thing out of whack:

  • group A 1

  • group A 2

  • group B 1

  • group B 2

  • group B 3

So far, workaround I found is to put empty paragraph in there

  • group A 1
  • group A 2

- group B 1 - group B 2 - group B 3

You generally cannot mix loose and tight spacing of lists in Markdown. Either the list is tight (no spaces) or loose (always spaces). Mixing the two within the same list will result in strangeness.

You should try in Babelmark to see what I mean

Or for more

So it seems common mark is the only one that I feel gets this correct

* List 1, Item 1
* List 1, Item 2
* List 1, Item 3
  
- List 2, Item 1
- List 2, Item 2
- List 2, Item 3

Common Mark/Cheapskates output:

Output in Discourse

  • List 1, Item 1
  • List 1, Item 2
  • List 1, Item 3
  • List 2, Item 1
  • List 2, Item 2
  • List 2, Item 3

I haven’t found a way to permit the following in any of the implementations yet:

* List 1, Item 1
* List 1, Item 2
* List 1, Item 3
  
* List 2, Item 1
* List 2, Item 2
* List 2, Item 3

Hacky, but inserting an HTML br tag seems to work

* List 1, Item 1  
* List 1, Item 2  
* List 1, Item 3  
<br>  
- List 2, Item 1
- List 2, Item 2
- List 2, Item 3
  • List 1, Item 1
  • List 1, Item 2
  • List 1, Item 3

  • List 2, Item 1
  • List 2, Item 2
  • List 2, Item 3

Except that you really only get a single <ul>:

Thanks for catching that. I hadn’t looked at source.
I hadn’t had my coffee yet - that’s my excuse and I’m sticking with it.

This works better, but is far from being a perfect work-around. i.e. horizontal rule

* item A1
* item A2
* item A3
-----
- item B1
- item B2
- item B3
  • item A1
  • item A2
  • item A3

  • item B1
  • item B2
  • item B3

I’m not sure which one Discourse uses, but “pandoc” and a few others seem to get it right.

This is totally resolved with markdown.it which we introduced a year or so ago