Dave Jarvis' Repositories

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

Addresses syntax rendering issues

AuthorDave Jarvis <email>
Date2026-02-14 19:54:13 GMT-0800
Commit96146480184c1f667a10f68a799e1d34025903dc
Parent9bb9162
render/Highlighter.php
$patterns[] = "(?P<punctuation>[\\{\\}\\(\\)\\[\\]\\;\\,])";
+ // The "any" pattern ensures NO text remains raw
+ $patterns[] = "(?P<any>[\s\S])";
$combined = '/' . implode('|', $patterns) . '/msu';
return preg_replace_callback($combined, function ($matches) {
foreach ($matches as $key => $value) {
if (!is_numeric($key) && $value !== '') {
if ($key === 'string_interp') {
return $this->renderInterpolatedString($value);
}
- // Always encode the value here to prevent it from being treated as HTML
+ if ($key === 'any') {
+ return htmlspecialchars($value);
+ }
return '<span class="hl-' . $key . '">' . htmlspecialchars($value) . '</span>';
}
render/LanguageDefinitions.php
'comment' => '/()/s',
'string' => '/' . $str . '/',
- 'keyword' => '/(<\/?[a-zA-Z0-9:-]+\s*\/?>|<\?xml.*?\?>)/',
+ 'keyword' => '/(<\/?[a-zA-Z0-9:-]+|\s*\/?>|<\?xml|\?>)/',
'variable' => '/([a-zA-Z0-9:-]+=)/',
],
'html' => [
'comment' => '/()/s',
'string' => '/' . $str . '/',
- 'keyword' => '/(<\/?[a-zA-Z0-9:-]+\s*\/?>)/',
+ 'keyword' => '/(<\/?[a-zA-Z0-9:-]+|\s*\/?>)/',
'variable' => '/([a-zA-Z0-9:-]+=)/',
],
Delta7 lines added, 3 lines removed, 4-line increase