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

improve regex for custom property matching #3213

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions resources/js/build/wordpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export function wordpressThemeJson({
const rootContent = themeContent.slice(themeContent.indexOf('{') + 1, themeContent.lastIndexOf('}'))
const colorVariables = {}

const colorVarRegex = /--color-([^:]+):\s*([^;]+);/g
const colorVarRegex = /--color-([^:]+):\s*([^;}]+)[;}]?/g
let match

while ((match = colorVarRegex.exec(rootContent)) !== null) {
Expand Down Expand Up @@ -250,7 +250,7 @@ export function wordpressThemeJson({
})

const fontFamilies = []
const fontVarRegex = /--font-([^:]+):\s*([^;]+);/g
const fontVarRegex = /--font-([^:]+):\s*([^;}]+)[;}]?/g
while ((match = fontVarRegex.exec(rootContent)) !== null) {
const [, name, value] = match
if (!name.includes('-feature-settings') && !name.includes('-variation-settings')) {
Expand All @@ -263,7 +263,7 @@ export function wordpressThemeJson({
}

const fontSizes = []
const fontSizeVarRegex = /--text-([^:]+):\s*([^;]+);/g
const fontSizeVarRegex = /--text-([^:]+):\s*([^;}]+)[;}]?/g
while ((match = fontSizeVarRegex.exec(rootContent)) !== null) {
const [, name, value] = match
if (!name.includes('--line-height')) {
Expand Down