fix tailwind css regex mismatch (#3221)

This commit is contained in:
Matthias
2025-02-05 23:58:57 +01:00
committed by GitHub
parent 6012bf1886
commit 47a48480bd

View File

@@ -205,12 +205,28 @@ export function wordpressThemeJson({
fs.readFileSync(path.resolve('./theme.json'), 'utf8')
)
const themeMatch = cssContent.match(/@(?:layer\s+)?theme\s*{([^}]*)}/s)
if (!themeMatch) {
const themeContent = (() => {
const match = cssContent.match(/@(?:layer\s+)?theme\s*{/s)
if (!match[0]) {
return null
}
const startIndex = match.index + match[0].length;
let braceCount = 1;
for (let i = startIndex; i < cssContent.length; i++) {
if (cssContent[i] === "{") braceCount++;
if (cssContent[i] === "}") braceCount--;
if (braceCount === 0) {
return cssContent.substring(startIndex, i );
}
}
return null
})()
if (!themeContent) {
return;
}
const themeContent = themeMatch[1]
if (!themeContent.trim().startsWith(':root')) {
return;
}