-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add Basic CSS Color Parsing #24
Conversation
Codecov Report
@@ Coverage Diff @@
## main #24 +/- ##
=============================================
+ Coverage 42.70% 66.91% +24.20%
- Complexity 37 54 +17
=============================================
Files 16 27 +11
Lines 384 807 +423
Branches 52 66 +14
=============================================
+ Hits 164 540 +376
- Misses 197 238 +41
- Partials 23 29 +6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks so much for integrating this so soon! ❤️
private val RGB = """($HEX)($HEX)($HEX)""".toRegex(RegexOption.IGNORE_CASE) | ||
private val RGBA = """($HEX)($HEX)($HEX)($HEX)""".toRegex(RegexOption.IGNORE_CASE) | ||
private val RRGGBB = """($HEX{2})($HEX{2})($HEX{2})""".toRegex(RegexOption.IGNORE_CASE) | ||
private val RRGGBBAA = """($HEX{2})($HEX{2})($HEX{2})($HEX{2})""".toRegex(RegexOption.IGNORE_CASE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that regex approach is slower than processing by simple iteration.
But we can definitely postpone that optimization (and should benchmark to verify that regex is even slower).
Created #25 (super low priority though) to potentially address this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good to me
For now, only parses color keywords and hex notation (
#rgb
,#rgba
,#rrggbb
,#rrggbbaa
). In the future we should includergb()
function call syntax. As such, I'm considering this only a partial implementation of #22.Also wrote a few bonus tests since I was looking at the coverage report and they seemed fast.