commonmark / cmark

CommonMark parsing and rendering library and program in C
Other
1.62k stars 539 forks source link

Line spacing of items in an unordered list is different if an item contains a fenced code block with an blank line before #440

Closed regseb closed 2 years ago

regseb commented 2 years ago

The line spacing of items in an unordered list is different if an item contains a fenced code block with an blank line before (live demo).

I want to add a blank line to respect the blanks-around-fences rule of markdownlint:

Aside from aesthetic reasons, some parsers, including kramdown, will not parse fenced code blocks that don't have blank lines before and after them.

✔️ Unordered list without fenced code block

Markdown

- foo
- bar
- baz

Rendering

✔️ Unordered list with fenced code block without blank line

Markdown

- foo
- bar
  ```
  baz
  ```

Rendering

❌ Unordered list with fenced code block with blank line

Markdown

- foo
- bar

  ```
  baz
  ```

Rendering

jgm commented 2 years ago

This is in accordance with what the spec says about tight vs loose lists, isn't it?

jgm commented 2 years ago

So, not a bug. See https://spec.commonmark.org/0.30/#loose