1
This commit is contained in:
@@ -175,29 +175,20 @@
|
|||||||
})
|
})
|
||||||
}, 300);
|
}, 300);
|
||||||
});
|
});
|
||||||
// // 英文截断处理
|
// 英文截断处理
|
||||||
// $('#rendered-content').html(function(i, html) {
|
$('#rendered-content').css({
|
||||||
// // 1. 保护只包含 的标签(包括嵌套情况)
|
'word-wrap': 'break-word',
|
||||||
// html = html.replace(/<([a-zA-Z][a-zA-Z0-9]*)(?:\s+[^>]*)?>(?:\s*<[^>]+>\s*)*( | )*(?:\s*<\/[^>]+>\s*)*<\/\1>/g, function(match) {
|
'overflow-wrap': 'break-word',
|
||||||
// // 统一格式为 <tag> </tag>
|
'word-break': 'normal',
|
||||||
// var tagName = match.match(/^<([a-zA-Z][a-zA-Z0-9]*)/)[1];
|
'white-space': 'normal',
|
||||||
// return '<' + tagName + '> </' + tagName + '>';
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
// // 2. 替换其他情况下的 (后面跟着字母或数字)
|
|
||||||
// html = html.replace(/ (?=[a-zA-Z0-9])/g, ' ');
|
|
||||||
|
|
||||||
// return html;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // 添加CSS样式
|
// 处理文本节点
|
||||||
// $('#rendered-content').css({
|
$('#rendered-content').find('*').contents().filter(function() {
|
||||||
// 'word-wrap': 'break-word',
|
return this.nodeType === 3;
|
||||||
// 'overflow-wrap': 'break-word',
|
}).each(function() {
|
||||||
// 'word-break': 'normal',
|
$(this).replaceWith(this.nodeValue.replace(/ /g, ' '));
|
||||||
// 'white-space': 'normal',
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{/block}
|
{/block}
|
||||||
Reference in New Issue
Block a user