Skip to content

Conversation

@SHARMA1525
Copy link

Deno’s HTML formatter was incorrectly inserting a space before square brackets in CSS property values inside style attributes. For example:

animation-[value] → animation- [value]

This resulted in invalid CSS syntax and caused issues when using bracket-notation utilities.

This PR adds a post-processing step to preserve valid -[ sequences after malva formats inline CSS. The new fix_css_bracket_spacing() function removes unintended spaces between hyphens and [ characters in CSS property values, ensuring that patterns such as animation-[value] remain correct and unchanged.

Summary of Changes

Added fix_css_bracket_spacing() to normalize bracket syntax after malva’s CSS formatting.

Integrated this fix into the HTML formatting pipeline for inline CSS inside style attributes.

Verified that the example from the issue formats correctly without inserting unwanted spaces.

Confirmed that no other CSS formatting behavior is affected.

Testing & Validation

Added/updated tests to cover this behavior.

cargo test --manifest-path cli/Cargo.toml tools::fmt::test passes.

./tools/format.js runs without producing any diffs.

./tools/lint.js passes.

Checklist

Descriptive PR title

References related issue (#30991)

Tests cover the change

cargo test passes

./tools/format.js passes

./tools/lint.js passes

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, but it feels to me like this should be fixed in https://github.com/g-plane/markup_fmt. Maybe it's actually already fixed and we only need to update the dependency.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants