Skip to content

Commit

Permalink
fix: remove special case of <label> tag (fix #95)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Jan 15, 2025
1 parent ee94c12 commit 4d59a5b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
17 changes: 8 additions & 9 deletions markup_fmt/src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2189,16 +2189,15 @@ where
/// Determines if a given node is "text-like".
/// Text-like nodes should remain on the same line whenever possible.
fn is_text_like(node: &Node) -> bool {
match &node.kind {
matches!(
node.kind,
NodeKind::Text(..)
| NodeKind::VueInterpolation(..)
| NodeKind::SvelteInterpolation(..)
| NodeKind::AstroExpr(..)
| NodeKind::JinjaInterpolation(..)
| NodeKind::VentoInterpolation(..) => true,
NodeKind::Element(element) => element.tag_name.eq_ignore_ascii_case("label"),
_ => false,
}
| NodeKind::VueInterpolation(..)
| NodeKind::SvelteInterpolation(..)
| NodeKind::AstroExpr(..)
| NodeKind::JinjaInterpolation(..)
| NodeKind::VentoInterpolation(..)
)
}

fn format_children_without_inserting_linebreak<'s, E, F>(
Expand Down
4 changes: 4 additions & 0 deletions markup_fmt/tests/fmt/html/whitespace/label.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<label></label>
<input>
</div>
7 changes: 7 additions & 0 deletions markup_fmt/tests/fmt/html/whitespace/label.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: markup_fmt/tests/fmt.rs
---
<div>
<label></label>
<input>
</div>

0 comments on commit 4d59a5b

Please sign in to comment.