From a61cfaf9d32f8fdb0a06be2afeecd2d3536d35c9 Mon Sep 17 00:00:00 2001 From: Fidel Remedios Rosado Date: Sat, 7 Feb 2026 22:52:40 -0500 Subject: [PATCH] Add REGEX_CLASS_ATTR_PARENS for class extraction Div::in("accion procesada")->class("p-4 bg-green-500 text-white") I need to add this pattern so it can be recognized within methods of a class, and you need to extend the `Tailwind::extractCandidates($content)` method so that new patterns can be created from the configuration file to achieve something like this: @import "tailwindcss"; @source "./app/**/*.php"; @patterns ["REGEX_CLASS_ATTR_PARENS"=>'/->class\s*\(\s*["\']([^"\']+)["\']\s*\)/']; --- src/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.php b/src/index.php index 1da8e72..d04ab62 100644 --- a/src/index.php +++ b/src/index.php @@ -82,6 +82,7 @@ * overhead in hot paths like extractCandidates() and theme value resolution. */ const REGEX_CLASS_ATTR = '/class\s*=\s*["\']([^"\']+)["\']/'; +const REGEX_CLASS_ATTR_PARENS = '/->class\s*\(\s*["\']([^"\']+)["\']\s*\)/'; const REGEX_CLASSNAME_ATTR = '/className\s*=\s*["\']([^"\']+)["\']/'; const REGEX_WHITESPACE = '/\s+/'; const REGEX_UNESCAPE = '/\\\\(.)/'; @@ -2108,7 +2109,7 @@ function extractCandidates(string $html): array $candidates = []; // Extract from class and className attributes - foreach ([REGEX_CLASS_ATTR, REGEX_CLASSNAME_ATTR] as $pattern) { + foreach ([REGEX_CLASS_ATTR, REGEX_CLASS_ATTR_PARENS ,REGEX_CLASSNAME_ATTR] as $pattern) { if (preg_match_all($pattern, $html, $matches)) { foreach ($matches[1] as $classAttr) { foreach (preg_split(REGEX_WHITESPACE, $classAttr) as $class) {