Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '/\\\\(.)/';
Expand Down Expand Up @@ -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) {
Expand Down