From 912d770c33b9db1895368cf61568497e4ba52ea4 Mon Sep 17 00:00:00 2001 From: liangjiami <2249412933@qq.com> Date: Thu, 17 Jul 2025 16:02:31 +0800 Subject: [PATCH] =?UTF-8?q?=C2=B71?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/view/mobile/topic_nas/help_detail.html | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/index/view/mobile/topic_nas/help_detail.html b/app/index/view/mobile/topic_nas/help_detail.html index 2157de44..91a91a7d 100644 --- a/app/index/view/mobile/topic_nas/help_detail.html +++ b/app/index/view/mobile/topic_nas/help_detail.html @@ -176,16 +176,15 @@ }, 300); }); // 英文截断处理 - // 处理 #rendered-content 内的内容 $('#rendered-content').html(function(i, html) { - // 1. 先保护所有可能的空行格式 - html = html.replace(/<(p|h[1-6])([^>]*)>(<[^>]+>)*\s*( )*\s*(<\/[^>]+>)*<\/\1>/gi, function(match) { - // 统一空行格式为

 

形式 - var tag = match.match(/<(p|h[1-6])/i)[1]; - return '<' + tag + '> '; + // 1. 保护只包含 的标签(包括嵌套情况) + html = html.replace(/<([a-zA-Z][a-zA-Z0-9]*)(?:\s+[^>]*)?>(?:\s*<[^>]+>\s*)*( | )*(?:\s*<\/[^>]+>\s*)*<\/\1>/g, function(match) { + // 统一格式为   + var tagName = match.match(/^<([a-zA-Z][a-zA-Z0-9]*)/)[1]; + return '<' + tagName + '> '; }); - // 2. 只替换单词间的  (确保后面跟着字母或数字) + // 2. 替换其他情况下的 (后面跟着字母或数字) html = html.replace(/ (?=[a-zA-Z0-9])/g, ' '); return html;