1
This commit is contained in:
@@ -176,33 +176,27 @@
|
|||||||
}, 300);
|
}, 300);
|
||||||
});
|
});
|
||||||
// 英文截断处理
|
// 英文截断处理
|
||||||
$('#rendered-content').html(function(i, html) {
|
// $('#rendered-content').html(function(i, html) {
|
||||||
// 1. 保护所有形式的空标签(包括带属性和嵌套)
|
// // 1. 保护只包含 的标签(包括嵌套情况)
|
||||||
html = html.replace(/<([a-zA-Z]+)(?:\s+[^>]*)?>(?:\s*<[^>]+>\s*)*\s*(?: |\s)+\s*(?:\s*<\/[^>]+>\s*)*<\/\1>/g, function(match) {
|
// html = html.replace(/<([a-zA-Z][a-zA-Z0-9]*)(?:\s+[^>]*)?>(?:\s*<[^>]+>\s*)*( | )*(?:\s*<\/[^>]+>\s*)*<\/\1>/g, function(match) {
|
||||||
// 提取标签名
|
// // 统一格式为 <tag> </tag>
|
||||||
var tagName = match.match(/^<([a-zA-Z]+)/)[1];
|
// var tagName = match.match(/^<([a-zA-Z][a-zA-Z0-9]*)/)[1];
|
||||||
// 提取原有属性
|
// return '<' + tagName + '> </' + tagName + '>';
|
||||||
var attributes = (match.match(/<[a-zA-Z]+\s+([^>]+)>/) || ['', ''])[1];
|
// });
|
||||||
// 重建标签,保留原有属性
|
|
||||||
return '<' + tagName + (attributes ? ' ' + attributes : '') + '> </' + tagName + '>';
|
|
||||||
});
|
|
||||||
|
|
||||||
// 2. 只替换文本中的 (确保后面跟着字母或数字)
|
// // 2. 替换其他情况下的 (后面跟着字母或数字)
|
||||||
html = html.replace(/(^|>)([^<]*?) (?=[a-zA-Z0-9])/g, '$1$2 ');
|
// html = html.replace(/ (?=[a-zA-Z0-9])/g, ' ');
|
||||||
|
|
||||||
return html;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 添加CSS样式
|
|
||||||
$('#rendered-content').css({
|
|
||||||
'word-wrap': 'break-word',
|
|
||||||
'overflow-wrap': 'break-word',
|
|
||||||
'word-break': 'normal',
|
|
||||||
'white-space': 'normal',
|
|
||||||
'line-height': '1.6'
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// return html;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // 添加CSS样式
|
||||||
|
// $('#rendered-content').css({
|
||||||
|
// 'word-wrap': 'break-word',
|
||||||
|
// 'overflow-wrap': 'break-word',
|
||||||
|
// 'word-break': 'normal',
|
||||||
|
// 'white-space': 'normal',
|
||||||
|
// });
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user