commonmark.js icon indicating copy to clipboard operation
commonmark.js copied to clipboard

List tightness is sometimes wrong when a list contains a blockquote

Open lexi-lambda opened this issue 4 years ago • 1 comments

Consider the following markdown input:

* foo
  > bar
  >
  baz

Is this list loose or tight? Here’s what the spec says:

A list is loose if any of its constituent list items are separated by blank lines, or if any of its constituent list items directly contain two block-level elements with a blank line between them. Otherwise a list is tight.

This strongly suggests to me that the list should be tight, as it definitely does not directly contain two block-level elements with a blank line between them: the blank line is clearly contained in the blockquote. CommonMark implementations on babelmark3 agree, consistently interpreting the list as tight.

But what if we modify the input slightly? Let’s introduce an inner list:

* foo
  > * bar
  >
  baz

Surely this should have no impact whatsoever on whether the outer list is tight, since we just replaced a paragraph with a list inside the blockquote. But remarkably, a couple implementations on babelmark3, including commonmark.js, now interpret the outer list as loose. This seems like a bug.

lexi-lambda avatar Sep 11 '21 20:09 lexi-lambda

Correct: both should be tight lists (and cmark and commonmark-hs get this right). So this is a bug in commonmark.js.

jgm avatar Sep 12 '21 00:09 jgm

I can't reproduce this bug with the dingus. It looks like https://github.com/commonmark/commonmark.js/commit/df3ea1e80d98fce5ad7c72505f9230faa6f23492 fixed it.

notriddle avatar Feb 24 '24 04:02 notriddle

I love accidentally fixing bugs!

jgm avatar Feb 26 '24 18:02 jgm