Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Dec 13, 2024
2 parents c7512ce + c2dda66 commit a4b38b7
Show file tree
Hide file tree
Showing 10 changed files with 3,296 additions and 49 deletions.
2 changes: 2 additions & 0 deletions crates/biome_formatter/Source/format_element/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ pub trait Label {
pub enum VerbatimKind {
Bogus,
Suppressed,
/// This was intentionally skipped, not as a result of suppression.
Skipped,
Verbatim {
/// the length of the formatted node
length: TextSize,
Expand Down
1 change: 1 addition & 0 deletions crates/biome_formatter/Source/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub use crate::format_element::document::Document;
pub use crate::format_element::tag::{LabelId, Tag, TagKind};
pub use crate::verbatim::{
format_bogus_node, format_or_verbatim, format_suppressed_node, format_verbatim_node,
format_verbatim_skipped,
};

pub use crate::{
Expand Down
10 changes: 10 additions & 0 deletions crates/biome_formatter/Source/verbatim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ pub fn format_verbatim_node<L: Language>(node: &SyntaxNode<L>) -> FormatVerbatim
}
}

/// "Formats" a node according to its original formatting in the source text. It's functionally equal to
/// [`format_verbatim_node`], but it doesn't track the node as [VerbatimKind::Verbatim].
pub fn format_verbatim_skipped<L: Language>(node: &SyntaxNode<L>) -> FormatVerbatimNode<L> {
FormatVerbatimNode {
node,
kind: VerbatimKind::Skipped,
format_comments: true,
}
}

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct FormatVerbatimNode<'node, L: Language> {
node: &'node SyntaxNode<L>,
Expand Down
27 changes: 19 additions & 8 deletions crates/biome_html_formatter/Source/html/auxiliary/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@ impl FormatNodeRule<HtmlElement> for FormatHtmlElement {
closing_element,
} = node.as_fields();

write!(
f,
[
opening_element.format(),
children.format(),
closing_element.format(),
]
)?;
let tag_name = opening_element
.clone()
.and_then(|e| e.name())
.map(|e| e.text())
.unwrap_or_default();
// `pre` tags are "preformatted", so we should not format the content inside them. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
// We ignore the `script` and `style` tags as well, since embedded language parsing/formatting is not yet implemented.
let should_be_verbatim = ["script", "style", "pre"]
.iter()
.any(|tag| tag_name.eq_ignore_ascii_case(tag));

write!(f, [opening_element.format()])?;
if should_be_verbatim {
format_verbatim_skipped(children.syntax()).fmt(f)?;
write!(f, [hard_line_break()])?;
} else {
write!(f, [children.format()])?;
}
write!(f, [closing_element.format()])?;

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_html_formatter/Source/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[allow(unused_imports)]
pub(crate) use crate::{
format_verbatim_node, AsFormat, FormatNodeRule, FormatResult, FormatRule, FormattedIterExt,
HtmlFormatContext, HtmlFormatter,
format_verbatim_node, format_verbatim_skipped, AsFormat, FormatNodeRule, FormatResult,
FormatRule, FormattedIterExt, HtmlFormatContext, HtmlFormatter,
};
pub(crate) use biome_formatter::prelude::*;
#[allow(unused_imports)]
Expand Down
13 changes: 13 additions & 0 deletions crates/biome_html_formatter/tests/specs/html/elements/pre.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<pre>
___ ___ ___ ___
/\ \ ___ /\ \ /\__\ /\ \
/::\ \ /\ \ /::\ \ /::| | /::\ \
/:/\:\ \ \:\ \ /:/\:\ \ /:|:| | /:/\:\ \
/::\~\:\__\ /::\__\ /:/ \:\ \ /:/|:|__|__ /::\~\:\ \
/:/\:\ \:|__| __/:/\/__/ /:/__/ \:\__\ /:/ |::::\__\ /:/\:\ \:\__\
\:\~\:\/:/ / /\/:/ / \:\ \ /:/ / \/__/~~/:/ / \:\~\:\ \/__/
\:\ \::/ / \::/__/ \:\ /:/ / /:/ / \:\ \:\__\
\:\/:/ / \:\__\ \:\/:/ / /:/ / \:\ \/__/
\::/__/ \/__/ \::/ / /:/ / \:\__\
~~ \/__/ \/__/ \/__/
</pre>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: elements/pre.html
---
# Input

```html
<pre>
___ ___ ___ ___
/\ \ ___ /\ \ /\__\ /\ \
/::\ \ /\ \ /::\ \ /::| | /::\ \
/:/\:\ \ \:\ \ /:/\:\ \ /:|:| | /:/\:\ \
/::\~\:\__\ /::\__\ /:/ \:\ \ /:/|:|__|__ /::\~\:\ \
/:/\:\ \:|__| __/:/\/__/ /:/__/ \:\__\ /:/ |::::\__\ /:/\:\ \:\__\
\:\~\:\/:/ / /\/:/ / \:\ \ /:/ / \/__/~~/:/ / \:\~\:\ \/__/
\:\ \::/ / \::/__/ \:\ /:/ / /:/ / \:\ \:\__\
\:\/:/ / \:\__\ \:\/:/ / /:/ / \:\ \/__/
\::/__/ \/__/ \::/ / /:/ / \:\__\
~~ \/__/ \/__/ \/__/
</pre>
```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Attribute Position: Auto
-----

```html
<pre>___ ___ ___ ___
/\ \ ___ /\ \ /\__\ /\ \
/::\ \ /\ \ /::\ \ /::| | /::\ \
/:/\:\ \ \:\ \ /:/\:\ \ /:|:| | /:/\:\ \
/::\~\:\__\ /::\__\ /:/ \:\ \ /:/|:|__|__ /::\~\:\ \
/:/\:\ \:|__| __/:/\/__/ /:/__/ \:\__\ /:/ |::::\__\ /:/\:\ \:\__\
\:\~\:\/:/ / /\/:/ / \:\ \ /:/ / \/__/~~/:/ / \:\~\:\ \/__/
\:\ \::/ / \::/__/ \:\ /:/ / /:/ / \:\ \:\__\
\:\/:/ / \:\__\ \:\/:/ / /:/ / \:\ \/__/
\::/__/ \/__/ \::/ / /:/ / \:\__\
~~ \/__/ \/__/ \/__/
</pre>
```
83 changes: 55 additions & 28 deletions packages/@biomejs/backend-jsonrpc/package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,57 @@
{
"name": "@codeeditorland/backend-jsonrpc",
"description": "Bindings to the JSON-RPC Workspace API of the Biome daemon",
"main": "dist/index.js",
"files": [
"dist/",
"README.md",
"LICENSE-APACHE",
"LICENSE-MIT",
"ROME-LICENSE-MIT"
],
"scripts": {
"build": "tsc",
"test:ci": "pnpm build && vitest run"
},
"dependencies": {},
"devDependencies": {
"@types/node": "20.17.9"
},
"optionalDependencies": {
"@biomejs/cli-darwin-arm64": "1.9.4",
"@biomejs/cli-darwin-x64": "1.9.4",
"@biomejs/cli-linux-arm64": "1.9.4",
"@biomejs/cli-linux-arm64-musl": "1.9.4",
"@biomejs/cli-linux-x64": "1.9.4",
"@biomejs/cli-linux-x64-musl": "1.9.4",
"@biomejs/cli-win32-arm64": "1.9.4",
"@biomejs/cli-win32-x64": "1.9.4"
}
"name": "@biomejs/backend-jsonrpc",
"version": "1.9.3",
"main": "dist/index.js",
"scripts": {
"test": "vitest",
"test:ci": "pnpm build && vitest run",
"tsc": "tsc --noEmit",
"build": "tsc"
},
"files": [
"dist/",
"README.md",
"LICENSE-APACHE",
"LICENSE-MIT",
"ROME-LICENSE-MIT"
],
"homepage": "https://biomejs.dev",
"repository": {
"type": "git",
"url": "git+https://github.com/biomejs/biome.git",
"directory": "npm/backend-jsonrpc"
},
"author": "Biome Developers and Contributors",
"bugs": "https://github.com/biomejs/biome/issues",
"description": "Bindings to the JSON-RPC Workspace API of the Biome daemon",
"keywords": [
"JavaScript",
"TypeScript",
"format",
"lint",
"toolchain"
],
"engines": {
"node": ">=14.21.3"
},
"license": "MIT OR Apache-2.0",
"devDependencies": {
"@types/node": "20.17.10",
"typescript": "5.7.2",
"vite": "5.4.11",
"vitest": "1.6.0"
},
"publishConfig": {
"provenance": true
},
"optionalDependencies": {
"@biomejs/cli-win32-x64": "1.9.4",
"@biomejs/cli-win32-arm64": "1.9.4",
"@biomejs/cli-darwin-x64": "1.9.4",
"@biomejs/cli-darwin-arm64": "1.9.4",
"@biomejs/cli-linux-x64": "1.9.4",
"@biomejs/cli-linux-arm64": "1.9.4",
"@biomejs/cli-linux-x64-musl": "1.9.4",
"@biomejs/cli-linux-arm64-musl": "1.9.4"
}
}
26 changes: 15 additions & 11 deletions packages/tailwindcss-config-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{
"name": "tailwindcss-config-analyzer",
"description": "Tools to introspect Tailwind CSS configurations for integration with Biome",
"scripts": {
"prepublishOnly": "Build 'Source/**/*.ts'"
},
"dependencies": {},
"devDependencies": {
"@playform/build": "0.2.0",
"@types/bun": "1.1.14",
"read-package-up": "11.0.0"
}
"name": "tailwindcss-config-analyzer",
"version": "1.0.0",
"description": "Tools to introspect Tailwind CSS configurations for integration with Biome",
"private": true,
"license": "MIT OR Apache-2.0",
"author": "Dani Guardiola",
"type": "module",
"dependencies": {
"tailwindcss": "^3.4.16"
},
"devDependencies": {
"@types/bun": "1.1.14",
"read-package-up": "11.0.0",
"typescript": "5.7.2"
}
}
Loading

0 comments on commit a4b38b7

Please sign in to comment.