Skip to content

feat(format/html): format the style attribute as CSS#11080

Draft
dyc3 wants to merge 2 commits into
dyc3/html-srcset-attributefrom
dyc3/html-style-attribute-css
Draft

feat(format/html): format the style attribute as CSS#11080
dyc3 wants to merge 2 commits into
dyc3/html-srcset-attributefrom
dyc3/html-style-attribute-css

Conversation

@dyc3

@dyc3 dyc3 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR makes it so style attributes in HTML are treated as embedded css declaration snippets, and they get formatted on one line instead of a block.

implemented by opus 5

supercedes #10159

Test Plan

Docs


Stack created with GitHub Stacks CLIGive Feedback 💬

The value of a `style` attribute is a list of CSS declarations, but it
was printed exactly as written, so whatever spacing it was pasted with
stayed. It now goes through the CSS formatter, the way a `<style>`
element already did.

An attribute is not a block: the declarations stay on the tag's line
while they fit and break onto their own lines once they do not, and the
last one only takes a semicolon in the broken form. That is what
`CssEmbeddingKind::HtmlStyleAttribute` selects, reusing the snippet root
that already parses a bare declaration list. Such a list ends at the end
of its input rather than at a `}`, so the final semicolon is now
optional there — `style="color: red"` is how everyone writes it.

Two supporting fixes:

The trailing hard line break after embedded content moves from the
`EndEmbedded` tag into the callers that wrap it. A block wants that
break; an attribute value must not have one, since it would force the
attribute onto its own line whatever its length.

The formatter now knows which ranges have a parsed document waiting, as
the JavaScript formatter already did. A hole nothing fills prints as
nothing, so leaving one for a value that was never parsed would silently
empty the attribute.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 97ae9ff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added A-CLI Area: CLI A-Project Area: project A-Parser Area: parser A-Formatter Area: formatter L-CSS Language: CSS and super languages L-HTML Language: HTML and super languages labels Jul 26, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 26, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 5.07%

⚡ 3 improved benchmarks
✅ 179 untouched benchmarks
⏩ 93 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
synthetic/vue-dynamic-args.vue[cached] 656.4 µs 614.2 µs +6.88%
synthetic/vue-dynamic-args.vue[uncached] 744.7 µs 710.3 µs +4.83%
db_17847247775464589309.json[uncached] 14.2 ms 13.7 ms +3.54%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing dyc3/html-style-attribute-css (97ae9ff) with main (5a36427)2

Open in CodSpeed

Footnotes

  1. 93 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on dyc3/html-srcset-attribute (a504b59) during the generation of this report, so main (5a36427) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Formatter Area: formatter A-Parser Area: parser A-Project Area: project L-CSS Language: CSS and super languages L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant