File tree Expand file tree Collapse file tree 4 files changed +60
-2
lines changed
crates/biome_html_formatter
tests/specs/html/elements/inline Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @biomejs/biome " : patch
3+ ---
4+
5+ Fixed an issue where the HTML formatter mangled the closing ` > ` of inline elements when followed by self-closing elements like ` <br> ` or ` <img> ` .
Original file line number Diff line number Diff line change @@ -763,11 +763,17 @@ impl FormatHtmlElementList {
763763 // Take any borrowed `>` from the previous sibling element
764764 let current_borrowed_r_angle = borrowed_sibling_r_angle. take ( ) ;
765765
766+ let next_can_borrow = next_is_adjacent_inline
767+ && matches ! (
768+ children_iter. peek( ) ,
769+ Some ( HtmlChild :: NonText ( AnyHtmlElement :: HtmlElement ( _) ) )
770+ ) ;
771+
766772 // Create the element formatter with borrowing options
767773 let element_format = format_element_with_borrowing (
768774 non_text,
769775 current_borrowed_r_angle,
770- next_is_adjacent_inline ,
776+ next_can_borrow ,
771777 ) ;
772778
773779 if needs_outer_group {
@@ -864,7 +870,9 @@ impl FormatHtmlElementList {
864870 if next_is_adjacent_inline {
865871 prev_inline_group_id = Some ( non_text_group_id) ;
866872 // Store the closing r_angle token from this element for the next sibling
867- borrowed_sibling_r_angle = non_text. closing_r_angle_token ( ) ;
873+ if next_can_borrow {
874+ borrowed_sibling_r_angle = non_text. closing_r_angle_token ( ) ;
875+ }
868876 } else {
869877 prev_inline_group_id = None ;
870878 }
Original file line number Diff line number Diff line change 1+ < code > cubing.js</ code > < br >
2+ < span > foo</ span > < br >
3+ < b > bar</ b > < br >
4+ < a > link</ a > < img >
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / biome_formatter_test / src / snapshot_builder .rs
3+ info : elements / inline / inline - before - self - closing .html
4+ -- -
5+ # Input
6+
7+ ` ` ` html
8+ <code >cubing.js</code ><br >
9+ <span >foo</span ><br >
10+ <b >bar</b ><br >
11+ <a >link</a ><img >
12+
13+ ```
14+
15+
16+ =============================
17+
18+ # Outputs
19+
20+ ## Output 1
21+
22+ -----
23+ Indent style: Tab
24+ Indent width: 2
25+ Line ending: LF
26+ Line width: 80
27+ Attribute Position: Auto
28+ Bracket same line: false
29+ Whitespace sensitivity: css
30+ Indent script and style: false
31+ Self close void elements: never
32+ Trailing newline: true
33+ -----
34+
35+ ```html
36+ <code >cubing.js</code ><br >
37+ <span >foo</span ><br >
38+ <b >bar</b ><br >
39+ <a >link</a ><img >
40+
41+ ```
You can’t perform that action at this time.
0 commit comments