-
-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(css_formatter): CssNamespaceAtRule formatting (#2182)
- Loading branch information
1 parent
d2c70d6
commit 70bce5a
Showing
5 changed files
with
77 additions
and
183 deletions.
There are no files selected for viewing
23 changes: 20 additions & 3 deletions
23
crates/biome_css_formatter/src/css/statements/namespace_at_rule.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::CssNamespaceAtRule; | ||
use biome_rowan::AstNode; | ||
use biome_css_syntax::{CssNamespaceAtRule, CssNamespaceAtRuleFields}; | ||
use biome_formatter::write; | ||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssNamespaceAtRule; | ||
impl FormatNodeRule<CssNamespaceAtRule> for FormatCssNamespaceAtRule { | ||
fn fmt_fields(&self, node: &CssNamespaceAtRule, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let CssNamespaceAtRuleFields { | ||
namespace_token, | ||
prefix, | ||
url, | ||
semicolon_token, | ||
} = node.as_fields(); | ||
|
||
write!( | ||
f, | ||
[ | ||
namespace_token.format(), | ||
space(), | ||
prefix.format(), | ||
space(), | ||
url.format(), | ||
semicolon_token.format(), | ||
] | ||
) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
crates/biome_css_formatter/tests/specs/css/atrule/namespace.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@namespace empty ""; | ||
@namespace ""; | ||
@namespace url(http://www.w3.org/1999/xhtml); | ||
@namespace url("http://www.w3.org/1999/xhtml"); | ||
@namespace svg url(http://www.w3.org/2000/svg); | ||
@namespace svg url("http://www.w3.org/2000/svg"); | ||
@namespace "http://www.w3.org/1999/xhtml"; | ||
@namespace svg "http://www.w3.org/2000/svg"; |
43 changes: 43 additions & 0 deletions
43
crates/biome_css_formatter/tests/specs/css/atrule/namespace.css.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
source: crates/biome_formatter_test/src/snapshot_builder.rs | ||
info: css/atrule/namespace.css | ||
--- | ||
# Input | ||
|
||
```css | ||
@namespace empty ""; | ||
@namespace ""; | ||
@namespace url(http://www.w3.org/1999/xhtml); | ||
@namespace url("http://www.w3.org/1999/xhtml"); | ||
@namespace svg url(http://www.w3.org/2000/svg); | ||
@namespace svg url("http://www.w3.org/2000/svg"); | ||
@namespace "http://www.w3.org/1999/xhtml"; | ||
@namespace svg "http://www.w3.org/2000/svg"; | ||
|
||
``` | ||
|
||
|
||
============================= | ||
|
||
# Outputs | ||
|
||
## Output 1 | ||
|
||
----- | ||
Indent style: Tab | ||
Indent width: 2 | ||
Line ending: LF | ||
Line width: 80 | ||
Quote style: Double Quotes | ||
----- | ||
|
||
```css | ||
@namespace empty ""; | ||
@namespace ""; | ||
@namespace url(http://www.w3.org/1999/xhtml); | ||
@namespace url("http://www.w3.org/1999/xhtml"); | ||
@namespace svg url(http://www.w3.org/2000/svg); | ||
@namespace svg url("http://www.w3.org/2000/svg"); | ||
@namespace "http://www.w3.org/1999/xhtml"; | ||
@namespace svg "http://www.w3.org/2000/svg"; | ||
``` |
174 changes: 0 additions & 174 deletions
174
crates/biome_css_formatter/tests/specs/prettier/css/atrule/namespaces.css.snap
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters