Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(css_formatter): use format_number_token utils for css number #2769

Merged
merged 1 commit into from
May 8, 2024

Conversation

denbezrukov
Copy link
Contributor

Summary

Use format_number_token to format CSS numbers like we do for JS/JSON numbers

Test Plan

cargo test -p biome_css_formatter

@github-actions github-actions bot added A-Formatter Area: formatter L-CSS Language: CSS labels May 8, 2024
Comment on lines -139 to -147
+ a: 1E1;
+ a: 1E+1;
+ a: 1E-1;
+ a: 1.E1;
+ a: .1E1;
+ a: 1.1E1;
+ a: 1.1E0010;
+ a: .1E+0010;
+ a: .1E-0010;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is correct. It should print with lowercase e

Copy link
Contributor Author

@denbezrukov denbezrukov May 8, 2024

Choose a reason for hiding this comment

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

Yes, you're right; it's problematic how GitHub displays changes. This code was about the differences between our formatting and Prettier's, but it has now been removed.

However there is a problem with a number parsing and I'm unsure how to handle it better.

a: 1.;
a: 0.e60;

our parser can't parse these number because according to spec: https://drafts.csswg.org/css-syntax-3/#consume-number

If the next 2 input code points are U+002E FULL STOP (.) followed by a digit, then:
Consume the next input code point and append it to number part.
While the next input code point is a digit, consume it and append it to number part.
Set type to "number".

Copy link

codspeed-hq bot commented May 8, 2024

CodSpeed Performance Report

Merging #2769 will not alter performance

Comparing feat/css-number-formatting (296e463) with main (b29ac6f)

Summary

✅ 85 untouched benchmarks

@denbezrukov denbezrukov merged commit d74b584 into main May 8, 2024
15 checks passed
@denbezrukov denbezrukov deleted the feat/css-number-formatting branch May 8, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-CSS Language: CSS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants