代码块中的尖括号处理

This commit is contained in:
2025-08-04 17:59:33 +08:00
parent 26e0f0fc0a
commit c7c1f55cd4

View File

@@ -5,5 +5,11 @@ function MarkdownEntities($markdown) {
$markdown = preg_replace_callback('/\$\$(.*?)\$\$/s', function ($matches) {
return str_replace(['<', '>'], ['\\lt', '\\gt'], $matches[0]);
}, $markdown);
$markdown = preg_replace_callback('/```(.*?)```/s', function ($matches) {
return str_replace(['<', '>'], ['&lt;', '&gt;'], $matches[0]);
}, $markdown);
$markdown = preg_replace_callback('/`(.*?)`/s', function ($matches) {
return str_replace(['<', '>'], ['&lt;', '&gt;'], $matches[0]);
}, $markdown);
return $markdown;
}