From 856ce0e7ccb4f008eb272cc1d833e9fe09658fad Mon Sep 17 00:00:00 2001 From: liangjiami <2249412933@qq.com> Date: Thu, 17 Jul 2025 15:40:29 +0800 Subject: [PATCH] 1 --- .../view/mobile/topic_nas/help_detail.html | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/index/view/mobile/topic_nas/help_detail.html b/app/index/view/mobile/topic_nas/help_detail.html index 24651d2b..2157de44 100644 --- a/app/index/view/mobile/topic_nas/help_detail.html +++ b/app/index/view/mobile/topic_nas/help_detail.html @@ -176,30 +176,29 @@ }, 300); }); // 英文截断处理 + // 处理 #rendered-content 内的内容 $('#rendered-content').html(function(i, html) { - // 1. 先保护所有标签内的内容(包括标签内的 ) - html = html.replace(/<[^>]+>[^<]*<\/[^>]+>/g, function(match) { - return match.replace(//g, '___TAG_CLOSE___'); + // 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 + '> ' + tag + '>'; }); - // 2. 替换非标签内容中的 为普通空格 - html = html.replace(/ /g, ' '); - - // 3. 恢复被保护的标签内容 - html = html.replace(/___TAG_OPEN___/g, '<') - .replace(/___TAG_CLOSE___/g, '>'); + // 2. 只替换单词间的 (确保后面跟着字母或数字) + html = html.replace(/ (?=[a-zA-Z0-9])/g, ' '); return html; }); - // 添加CSS样式确保英文单词完整换行 + // 添加CSS样式 $('#rendered-content').css({ 'word-wrap': 'break-word', 'overflow-wrap': 'break-word', 'word-break': 'normal', 'white-space': 'normal', }); + }); {/block} \ No newline at end of file