Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Updates highlighter with class detection

AuthorDave Jarvis <email>
Date2026-02-14 19:31:36 GMT-0800
Commit737dfa915aab216b9ccc3983c1f3939899106818
Parent5aeceec
render/Highlighter.php
foreach ($this->rules as $name => $pattern) {
$delim = $pattern[0];
- $inner = substr($pattern, 1, strrpos($pattern, $delim) - 1);
+ $lastDelimPos = strrpos($pattern, $delim);
+ $inner = substr($pattern, 1, $lastDelimPos - 1);
$patterns[] = "(?P<$name>$inner)";
}
$patterns[] = "(?P<punctuation>[\\{\\}\\(\\)\\[\\]\\;\\,])";
- $combined = '/' . implode('|', $patterns) . '/msu';
+
+ $combined = '/' . implode('|', $patterns) . '/msu';
return preg_replace_callback($combined, function ($matches) {
render/LanguageDefinitions.php
'string_interp' => '/(".*?")/',
'string' => '/(\'.*?\')/',
- '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)/',
+ '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]*)/',
'number' => '/' . $int . '/',
Delta6 lines added, 4 lines removed, 2-line increase