From 567798643c05ff4f8e9172e5db67997da73b3fa3 Mon Sep 17 00:00:00 2001 From: liangjiami <2249412933@qq.com> Date: Thu, 17 Jul 2025 16:11:01 +0800 Subject: [PATCH] 1 --- .../view/mobile/topic_nas/help_detail.html | 20 ++++++++++++------- 1 file changed, 13 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 91a91a7d..d2b65670 100644 --- a/app/index/view/mobile/topic_nas/help_detail.html +++ b/app/index/view/mobile/topic_nas/help_detail.html @@ -177,15 +177,18 @@ }); // 英文截断处理 $('#rendered-content').html(function(i, html) { - // 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 + '> '; + // 1. 保护所有形式的空标签(包括带属性和嵌套) + html = html.replace(/<([a-zA-Z]+)(?:\s+[^>]*)?>(?:\s*<[^>]+>\s*)*\s*(?: |\s)+\s*(?:\s*<\/[^>]+>\s*)*<\/\1>/g, function(match) { + // 提取标签名 + var tagName = match.match(/^<([a-zA-Z]+)/)[1]; + // 提取原有属性 + var attributes = (match.match(/<[a-zA-Z]+\s+([^>]+)>/) || ['', ''])[1]; + // 重建标签,保留原有属性 + return '<' + tagName + (attributes ? ' ' + attributes : '') + '> '; }); - // 2. 替换其他情况下的 (后面跟着字母或数字) - html = html.replace(/ (?=[a-zA-Z0-9])/g, ' '); + // 2. 只替换文本中的  (确保后面跟着字母或数字) + html = html.replace(/(^|>)([^<]*?) (?=[a-zA-Z0-9])/g, '$1$2 '); return html; }); @@ -196,7 +199,10 @@ 'overflow-wrap': 'break-word', 'word-break': 'normal', 'white-space': 'normal', + 'line-height': '1.6' }); + + });