Skip to content

[3.6 regression] Semantically changes Markdown loose list to tight list #17746

@andersk

Description

@andersk

Prettier 3.6.2
Playground link

# Options (if any):
--parser markdown

Input:

- a

  - b

Output:

- a
  - b

Expected output:

- a

  - b

Why?

According to the CommonMark spec:

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. (The difference in HTML output is that paragraphs in a loose list are wrapped in <p> tags, while paragraphs in a tight list are not.)

In this example, the loose version renders as

<ul>
  <li>
    <p>a</p>
    <ul>
      <li>b</li>
    </ul>
  </li>
</ul>
  • a

    • b

while the tight version renders as

<ul>
  <li>
    a
    <ul>
      <li>b</li>
    </ul>
  </li>
</ul>
  • a
    • b

The removed <p> visibly changes the vertical spacing. Prettier should not change the meaning of Markdown code by switching loose lists to tight or vice versa.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions