Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions include/layout.inc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ function highlight_php_trimmed($code, $return = false)
$highlighted_code = highlight_php($code, true);
$highlighted_code = preg_replace("!&lt;\?php(<br />)+!", '', $highlighted_code, 1);

// add syntax highlighting for variables
$variableReplacer = function (array $matches) {
if ($matches[1] !== '') {
$replacement = '<span class="default">' . $matches[1] . '</span>';
} else {
$replacement = '';
}
return $replacement . '<span class="variable">' . $matches[2] . '</span>';
};

$pattern = '!<span class="default">([\w\s]*)(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*\s*)</span>!';
$highlighted_code = preg_replace_callback($pattern, $variableReplacer, $highlighted_code);

if ($return) { return $highlighted_code; }
echo $highlighted_code;
return null;
Expand Down
4 changes: 2 additions & 2 deletions releases/8.5/release.inc
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ final class PostsController
)]
public function update(
Request $request,
Post $post
Post $post,
): Response {
// ...
}
Expand Down Expand Up @@ -545,7 +545,7 @@ final class PostsController
})]
public function update(
Request $request,
Post $post
Post $post,
): Response {
// ...
}
Expand Down
12 changes: 11 additions & 1 deletion styles/php85.css
Original file line number Diff line number Diff line change
Expand Up @@ -3564,6 +3564,11 @@ footer p:where(.dark,.dark *) {
background-color: transparent;
}

.php85 .phpcode span.variable {
color: #7d55ba;
background-color: transparent;
}

.php85 .phpcode span.keyword {
color: #07a;
background-color: transparent;
Expand All @@ -3585,13 +3590,18 @@ footer p:where(.dark,.dark *) {
background-color: transparent;
}

.dark .php85 .phpcode span.variable {
color: #a5d6ff;
background-color: transparent;
}

.dark .php85 .phpcode span.keyword {
color: #ff7b72;
background-color: transparent;
}

.dark .php85 .phpcode span.string {
color: #a5d6ff;
color: #80b83c;
background-color: transparent;
}

Expand Down
2 changes: 1 addition & 1 deletion styles/theme-medium.css
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ div.warning a:focus {
color: var(--dark-blue-color);
background-color: transparent;
}
div.phpcode span.default {
div.phpcode span.default, div.phpcode span.variable {
color: #369;
background-color: transparent;
}
Expand Down
Loading