fix color detection
parent
febded6864
commit
ba21a2f1d8
|
@ -51,18 +51,10 @@ const colorRegex = new RegExp(
|
||||||
function getColorsInString(str: string): (culori.Color | KeywordColor)[] {
|
function getColorsInString(str: string): (culori.Color | KeywordColor)[] {
|
||||||
if (/(?:box|drop)-shadow/.test(str)) return []
|
if (/(?:box|drop)-shadow/.test(str)) return []
|
||||||
|
|
||||||
return (
|
return Array.from(str.matchAll(colorRegex), (match) => {
|
||||||
str
|
let color = match[1].replace(/var\([^)]+\)/, '1')
|
||||||
.match(colorRegex)
|
return getKeywordColor(color) ?? culori.parse(color)
|
||||||
?.map((color) =>
|
}).filter(Boolean)
|
||||||
color
|
|
||||||
.trim()
|
|
||||||
.replace(/^[,(]|[,)]$/g, '')
|
|
||||||
.replace(/var\([^)]+\)/, '1')
|
|
||||||
)
|
|
||||||
.map((color) => getKeywordColor(color) ?? culori.parse(color))
|
|
||||||
.filter(Boolean) ?? []
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getColorFromDecls(
|
function getColorFromDecls(
|
||||||
|
|
Loading…
Reference in New Issue