File tree Expand file tree Collapse file tree 5 files changed +88
-4
lines changed
crates/biome_html_formatter
tests/specs/html/embedded/strict-whitespace-sensitivity Expand file tree Collapse file tree 5 files changed +88
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @biomejs/biome " : patch
3+ ---
4+
5+ Fixed a case where the HTML formatter would mangle embedded language tags if ` whitespaceSensitivity ` was set to ` strict `
Original file line number Diff line number Diff line change @@ -80,10 +80,14 @@ impl FormatNodeRule<HtmlElement> for FormatHtmlElement {
8080 // to borrow, while the child formatters are responsible for actually printing
8181 // the tokens. `HtmlElementList` prints them if they are borrowed, otherwise
8282 // they are printed by their original formatter.
83- let should_borrow_opening_r_angle =
84- is_whitespace_sensitive && !children. is_empty ( ) && !content_has_leading_whitespace;
85- let should_borrow_closing_tag =
86- is_whitespace_sensitive && !children. is_empty ( ) && !content_has_trailing_whitespace;
83+ let should_borrow_opening_r_angle = is_whitespace_sensitive
84+ && !children. is_empty ( )
85+ && !content_has_leading_whitespace
86+ && !should_be_verbatim;
87+ let should_borrow_closing_tag = is_whitespace_sensitive
88+ && !children. is_empty ( )
89+ && !content_has_trailing_whitespace
90+ && !should_be_verbatim;
8791
8892 let borrowed_r_angle = if should_borrow_opening_r_angle {
8993 opening_element. r_angle_token ( ) . ok ( )
Original file line number Diff line number Diff line change 1+ {
2+ "$schema" : " ../../../../../../../packages/@biomejs/biome/configuration_schema.json" ,
3+ "html" : {
4+ "formatter" : {
5+ "whitespaceSensitivity" : " strict"
6+ }
7+ }
8+ }
Original file line number Diff line number Diff line change 1+ < style >
2+ body {
3+ background-color : seagreen;
4+ }
5+ </ style >
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / biome_formatter_test / src / snapshot_builder .rs
3+ info : embedded / strict - whitespace - sensitivity / sensitive - style .html
4+ -- -
5+ # Input
6+
7+ ` ` ` html
8+ <style >
9+ body {
10+ background - color : seagreen ;
11+ }
12+ </style >
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+ ---- -
33+
34+ ` ` ` html
35+ <style >
36+ body {
37+ background - color : seagreen ;
38+ }
39+ </style >
40+ ` ` `
41+
42+ ## Output 1
43+
44+ ---- -
45+ Indent style : Tab
46+ Indent width : 2
47+ Line ending : LF
48+ Line width : 80
49+ Attribute Position : Auto
50+ Bracket same line : false
51+ Whitespace sensitivity : strict
52+ Indent script and style : false
53+ Self close void elements : never
54+ ---- -
55+
56+ ` ` ` html
57+ <style >
58+ body {
59+ background - color : seagreen ;
60+ }
61+ </style >
62+ ` ` `
You can’t perform that action at this time.
0 commit comments