| Author | Dave Jarvis <email> |
|---|---|
| Date | 2026-02-14 19:36:07 GMT-0800 |
| Commit | 7a332962341aee496f6663e972b67ca87db27bee |
| Parent | 737dfa9 |
| foreach ($this->rules as $name => $pattern) { | ||
| $delim = $pattern[0]; | ||
| - $lastDelimPos = strrpos($pattern, $delim); | ||
| - $inner = substr($pattern, 1, $lastDelimPos - 1); | ||
| + $inner = substr($pattern, 1, strrpos($pattern, $delim) - 1); | ||
| + // Fix: Use $name for the capture group instead of hardcoding 'punctuation' | ||
| $patterns[] = "(?P<$name>$inner)"; | ||
| } | ||
| + // Fix: Move punctuation outside the loop as a global fallback | ||
| $patterns[] = "(?P<punctuation>[\\{\\}\\(\\)\\[\\]\\;\\,])"; | ||
| - | ||
| - $combined = '/' . implode('|', $patterns) . '/msu'; | ||
| + $combined = '/' . implode('|', $patterns) . '/msu'; | ||
| return preg_replace_callback($combined, function ($matches) { |
| $rules = [ | ||
| 'php' => [ | ||
| + 'tag' => '/(<\?php|<\?|=\?>|\?>)/', | ||
| 'string_interp' => '/(".*?")/', | ||
| 'string' => '/(\'.*?\')/', | ||
| - 'comment' => '/((?-s:\/\/.*$)|(?-s:#.*$)|(?s:\/\*.*?(\*\/|$)))/m', | ||
| + 'comment' => '/((?-s:\/\/.*$)|(?-s:#.*$)|(?s:\/\*.*?\*\/))/m', | ||
| 'keyword' => '/\b(class|abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|new|or|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/', | ||
| 'variable' => '/(\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/', |
| } | ||
| +.hl-tag { | ||
| + color: #ff7b72; | ||
| +} | ||
| + |
| Delta | 10 lines added, 5 lines removed, 5-line increase |
|---|