From b7aac3633e704691d07a189a360ef4fffab55d9d Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Fri, 23 Jan 2026 19:17:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=A8=20PHP=20=E7=AB=AF=E5=A4=84?= =?UTF-8?q?=E7=90=86=20Mermaid=20=E4=BB=A3=E7=A0=81=E5=9D=97=E6=8D=A2?= =?UTF-8?q?=E8=A1=8C=E7=AC=A6=20-=20=E5=9C=A8=20the=5Fcontent=5Ffilter=20?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=20Mermaid=20=E9=A2=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=20-=20=E4=BD=BF=E7=94=A8=E6=AD=A3=E5=88=99=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E5=8C=B9=E9=85=8D=E4=BB=A3=E7=A0=81=E5=9D=97?= =?UTF-8?q?=20-=20=E8=A7=A3=E7=A0=81=20HTML=20=E5=AE=9E=E4=BD=93=E5=B9=B6?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E7=BC=96=E7=A0=81=20-=20=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E6=8D=A2=E8=A1=8C=E7=AC=A6=E5=9C=A8=E8=BE=93=E5=87=BA=E6=97=B6?= =?UTF-8?q?=E4=BF=9D=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index a7ac680..6472556 100644 --- a/functions.php +++ b/functions.php @@ -3566,6 +3566,24 @@ function argon_fancybox($content){ return $content; } function the_content_filter($content){ + // 处理 Mermaid 代码块,确保换行符正确 + if (get_option('argon_enable_mermaid') == 'true') { + // 匹配
... 或 ...
+ $content = preg_replace_callback(
+ '/(.*?)<\/code><\/pre>/is',
+ function($matches) {
+ $code = $matches[1];
+ // 解码 HTML 实体
+ $code = html_entity_decode($code, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+ // 去除首尾空白
+ $code = trim($code);
+ // 返回带换行符的代码块
+ return '' . htmlspecialchars($code, ENT_QUOTES, 'UTF-8') . '
';
+ },
+ $content
+ );
+ }
+
// 根据设置决定是否启用懒加载
if (get_option('argon_enable_lazyload') !== 'false') {
$content = argon_lazyload($content);
@@ -3574,7 +3592,7 @@ function the_content_filter($content){
$content = argon_fancybox($content);
}
global $post;
- $custom_css = get_post_meta($post -> ID, 'argon_custom_css', true);
+ $custom_css = get_post_meta($post->ID, 'argon_custom_css', true);
if (!empty($custom_css)){
$content .= "";
}