Skip to content

Commit 7719e5a

Browse files
committed
Respect blank line existnce before block html regardless of previous type
1 parent d1c5fe8 commit 7719e5a

3 files changed

Lines changed: 7 additions & 17 deletions

File tree

src/language-markdown/print/children.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,12 @@ function shouldPrePrintDoubleHardline(path, options) {
106106
(node.type === "list" || !path.callParent(isLooseListItem));
107107
}
108108
const isPrevNodePrettierIgnore = isPrettierIgnore(previous) === "next";
109-
const isBlockHtmlWithoutBlankLineBetweenPrevHtml =
109+
const isBlockHtmlWithoutBlankLineBetweenPrevNode =
110110
node.type === "html" &&
111-
previous.type === "html" &&
112-
previous.position.end.line + 1 === node.position.start.line;
113-
const isBlockHtmlWithoutBlankLineBetweenPrevParagraph =
114-
options.parser !== "mdx" &&
115-
node.type === "html" &&
116-
previous.type === "paragraph" &&
111+
previous &&
117112
previous.position.end.line + 1 === node.position.start.line;
113+
const isBlockHtmlWithoutBlankLineBetweenPrevHtml =
114+
previous.type === "html" && isBlockHtmlWithoutBlankLineBetweenPrevNode;
118115
const isHtmlDirectAfterListItem =
119116
node.type === "html" &&
120117
parent.type === "listItem" &&
@@ -125,8 +122,9 @@ function shouldPrePrintDoubleHardline(path, options) {
125122
isSiblingNode ||
126123
isInTightListItem ||
127124
isPrevNodePrettierIgnore ||
128-
isBlockHtmlWithoutBlankLineBetweenPrevHtml ||
129-
isBlockHtmlWithoutBlankLineBetweenPrevParagraph ||
125+
(options.parser === "mdx"
126+
? isBlockHtmlWithoutBlankLineBetweenPrevHtml
127+
: isBlockHtmlWithoutBlankLineBetweenPrevNode) ||
130128
isHtmlDirectAfterListItem
131129
);
132130
}

tests/format/markdown/html/__snapshots__/format.test.js.snap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ quoted sentence2</p>
2828
2929
=====================================output=====================================
3030
- A list item.
31-
3231
<details><summary>Summary</summary>
3332
<p>
3433
@@ -38,7 +37,6 @@ quoted sentence2</p>
3837
</details>
3938
4039
- A list item.
41-
4240
<blockquote>
4341
4442
<p>quoted sentence1<br>
@@ -79,7 +77,6 @@ quoted sentence2</p>
7977
8078
=====================================output=====================================
8179
- A list item.
82-
8380
<details><summary>Summary</summary>
8481
<p>
8582
@@ -89,7 +86,6 @@ quoted sentence2</p>
8986
</details>
9087
9188
- A list item.
92-
9389
<blockquote>
9490
9591
<p>quoted sentence1<br>
@@ -130,7 +126,6 @@ quoted sentence2</p>
130126
131127
=====================================output=====================================
132128
- A list item.
133-
134129
<details><summary>Summary</summary>
135130
<p>
136131
@@ -140,7 +135,6 @@ quoted sentence2</p>
140135
</details>
141136
142137
- A list item.
143-
144138
<blockquote>
145139
146140
<p>quoted sentence1<br>

tests/format/markdown/list/task-list/__snapshots__/format.test.js.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ printWidth: 80
2323
<summary><h2>Checklist</h2></summary>
2424
2525
- [ ] I checked for duplicate issues.
26-
2726
</details>
2827
<details>
2928
<summary><h2>Checklist</h2></summary>
3029
3130
- [ ] I checked for duplicate issues.
3231
- [ ] I checked for duplicate issues.
33-
3432
</details>
3533
3634
================================================================================

0 commit comments

Comments
 (0)