feat(format/html): format the style attribute as CSS#11080
Conversation
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 detectedLatest commit: 97ae9ff The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
Merging this PR will improve performance by 5.07%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
Summary
This PR makes it so
styleattributes 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 CLI • Give Feedback 💬