refactor: replace regex with jq filters

This commit is contained in:
Sam Nystrom 2023-03-28 21:13:22 -04:00
parent 8a32c1b089
commit fa18ce9559

View file

@ -2,7 +2,9 @@ map_values(map_values({
hex: .hex | ltrimstr("#"),
rgb: .raw | split(", ") | map(tonumber),
hsl: .hsl
| capture("hsl\\((?<h>\\d+),\\s*(?<s>\\d+)%,\\s*(?<l>\\d+)%\\)")
| map(tonumber)
| ltrimstr("hsl(")
| rtrimstr(")")
| split(", ")
| map(rtrimstr("%") | tonumber)
| [ .[0], .[1] / 100, .[2] / 100 ]
}))