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

Custom CSS Color 4 compliant css color parser #175

Merged
merged 2 commits into from
May 22, 2023

Conversation

kajkal
Copy link
Contributor

@kajkal kajkal commented May 22, 2023

Strict CSS color parser compliant with CSS Color 4 Specification.

maplibre-gl-js #2550

Main features:

  • does not round numbers to integers from the range 0..255: rgb(50% 0% 0%) is equal to rgb(127.5 0 0) not rgb(127 0 0) or rgb(128 0 0)
  • does not deviate from the syntax defined in the specification: rgb(50% 0 0) and rgb(50%,0% 0%) are treated as invalid

Differences with the specification:

  • does not support grad, rad or turn angle units: hsl(.25turn 50% 50%) is not supported
  • does not support none keyword: rgb(128 none none) is not supported
  • does not support comments inside rgb/hsl functions: rgb(/* R */ 10%, /* G */ 20%, /* B */ 30%) is not supported

If anyone were to ask, I checked the regexes for catastrophic backtracking - they are safe.

Launch Checklist

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality.
  • Document any changes to public APIs.
  • Post benchmark scores.
  • Add an entry to CHANGELOG.md under the ## main section.

@birkskyum
Copy link
Member

birkskyum commented May 22, 2023

@kajkal , thanks for this

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