Dave Jarvis' Repositories

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

Adds capture for tags in PHP

AuthorDave Jarvis <email>
Date2026-02-14 19:36:07 GMT-0800
Commit7a332962341aee496f6663e972b67ca87db27bee
Parent737dfa9
render/Highlighter.php
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) {
render/LanguageDefinitions.php
$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]*)/',
repo.css
}
+.hl-tag {
+ color: #ff7b72;
+}
+
Delta10 lines added, 5 lines removed, 5-line increase