File tree Expand file tree Collapse file tree
crates/oxc_formatter_markdown Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -211,6 +211,37 @@ though no type 7 block can interrupt a paragraph on a regular line.
211211Printed with the container's prefix the line is no longer lazy, so a blank line keeps the block apart;
212212Prettier prints it adjacent, and the next parse reads it as part of the paragraph.
213213
214+ ## list-after-html-block
215+
216+ - Why: semantics (prettier/prettier#17690)
217+ - Pin: `tests/fixtures/markdown/list-after-html-block.md`
218+
219+ ```markdown
220+ <!-- input -->
221+ - a
222+
223+ <div>
224+
225+ - b
226+
227+ <!-- ours -->
228+ - a
229+
230+ <div>
231+
232+ - b
233+
234+ <!-- prettier (the list item becomes html, one per pass) -->
235+ - a
236+
237+ <div>
238+ - b
239+ ```
240+
241+ A nested list after a type 6 / 7 HTML block keeps its blank line: only a blank line ends such a block.
242+ Prettier joins any list in a list item to the previous block, and the next parse reads the first list line as part of the html.
243+ Types 1 to 5 end at their end marker, so a list after them is printed adjacent as Prettier does.
244+
214245## list-marker-after-ignored-list
215246
216247- Why: semantics
Original file line number Diff line number Diff line change @@ -113,10 +113,12 @@ fn double_gap(
113113 return !after_definition && !multi_line;
114114 }
115115
116- // A nested list after a paragraph / code keeps its blank line (prettier#17746)
116+ // A nested list after a paragraph / code keeps its blank line, and after a type 6 / 7 HTML block,
117+ // which only a blank line ends (DIVERGENCES.md#list-after-html-block)
117118 if matches ! ( node, Block :: List ( _) )
118119 && matches ! ( parent, Parent :: ListItem { .. } )
119- && matches ! ( previous, Block :: CodeBlock ( _) | Block :: Paragraph ( _) )
120+ && ( matches ! ( previous, Block :: CodeBlock ( _) | Block :: Paragraph ( _) )
121+ || matches ! ( previous, Block :: HtmlBlock ( h) if h. kind >= 6 ) )
120122 && !adjacent
121123 {
122124 return true ;
Original file line number Diff line number Diff line change 1+ - list
2+
3+ <details ><summary ></summary >
4+
5+ 1 . item
6+
7+ 2 . item
8+
9+ </details >
10+
11+ - list
12+
13+ <div >
14+
15+ - item
16+ - item
17+
18+ </div >
19+
20+ - list
21+
22+ <custom-tag >
23+
24+ - item
25+
26+ - list
27+
28+ <!-- closed by its end marker -->
29+
30+ - item
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / oxc_formatter_markdown / tests / fixtures / mod .rs
3+ assertion_line : 50
4+ -- -
5+ ==================== Input ====================
6+ - list
7+
8+ <details ><summary ></summary >
9+
10+ 1. item
11+
12+ 2. item
13+
14+ </details >
15+
16+ - list
17+
18+ <div >
19+
20+ - item
21+ - item
22+
23+ </div >
24+
25+ - list
26+
27+ <custom-tag >
28+
29+ - item
30+
31+ - list
32+
33+ <!-- closed by its end marker -->
34+
35+ - item
36+
37+ ==================== Output ====================
38+ ------------------
39+ { printWidth : 80 }
40+ ------------------
41+ - list
42+
43+ <details ><summary ></summary >
44+
45+ 1. item
46+
47+ 2. item
48+
49+ </details >
50+
51+ - list
52+
53+ <div >
54+
55+ - item
56+ - item
57+
58+ </div >
59+
60+ - list
61+
62+ <custom-tag >
63+
64+ - item
65+
66+ - list
67+
68+ <!-- closed by its end marker -->
69+ - item
70+
71+ -------------------
72+ { printWidth : 100 }
73+ -------------------
74+ - list
75+
76+ <details ><summary ></summary >
77+
78+ 1. item
79+
80+ 2. item
81+
82+ </details >
83+
84+ - list
85+
86+ <div >
87+
88+ - item
89+ - item
90+
91+ </div >
92+
93+ - list
94+
95+ <custom-tag >
96+
97+ - item
98+
99+ - list
100+
101+ <!-- closed by its end marker -->
102+ - item
103+
104+ ===================== End =====================
You can’t perform that action at this time.
0 commit comments