You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[3.6 regression] Semantically changes Markdown loose list to tight list #17746
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.
The root cause was that shouldPrePrintDoubleHardline in children.js unconditionally returned true when a nested list followed a code block within a list item — regardless of whether a blank line existed in the original source.
Fixed by adding a blank line presence check to that branch: byplayer@e0164f127
Activity
byplayer commentedon Sep 8, 2025
#16637
This change was intended to fix an issue where Prettier was formatting data like this:
into this:
The change was not meant to remove the blank lines between topics. Therefore, it seems like a new bug.
BTW, I have one question regarding the formatting:
For a list like this:
Is it correct to keep it as it is, or is the correct format to reduce the blank lines between
list 2andlist 3to one?andersk commentedon Sep 8, 2025
From the CommonMark spec:
and:
So two blank lines are treated equivalently to one blank line in all cases.
🐛 fix(markdown): preserve blank lines in nested lists
📝 Add changelog for markdown blank line fix (prettier#17746)
✅ update snapshots for markdown blank line fix
byplayer commentedon Sep 9, 2025
I create PR #17857 .
I hope it will be reviewed soon.
andersk commentedon Dec 9, 2025
I found another case where we incorrectly convert a tight list to loose (with or without #17857):
Input:
Rendered
Output:
Rendered
c
d
🐛 fix(markdown): port blank line fix to children.js
byplayer commentedon Apr 8, 2026
Thanks for reporting this case!
The root cause was that
shouldPrePrintDoubleHardlineinchildren.jsunconditionally returnedtruewhen a nested list followed a code block within a list item — regardless of whether a blank line existed in the original source.Fixed by adding a blank line presence check to that branch: byplayer@e0164f127
Input:
Before (incorrect):
After (correct):
🐛 fix(markdown): preserve blank lines before nested list in MDX
📝 docs(markdown): improve changelog for prettier#17746
📝 docs(markdown): fix spellcheck error in changelog for prettier#17746
✅ test(markdown): cover code→nested-list blank-line path for prettier…
fisker commentedon Jun 4, 2026
Fixed by #17857
chore(deps): update pre-commit hook prettier to v3.8.4 (hetznercloud/…
Update dependency prettier to v3.8.4
Update dependency prettier to v3.8.4
chore(deps): update dependency prettier to v3.8.4 (#39)
⬆️ Update dependency prettier to ^3.9.5
⬆️ Update dependency prettier to ^3.9.6