上标离子不变色
This commit is contained in:
@@ -1965,11 +1965,28 @@ function initArticleHtml(htmlData, refs, type, otherList) {
|
||||
nextParagraph.style.color = commonSupColor;
|
||||
}
|
||||
$('.wen_rong .content-box .conthtmn sup').each(function () {
|
||||
var $this = $(this);
|
||||
var textContent = $(this).text().trim(); // 获取并清理文本内容
|
||||
|
||||
// 如果包含 + 或 - (离子的特征),直接跳过,不执行后面的标蓝逻辑
|
||||
if (/[+\-]/.test(textContent)) {
|
||||
return; // 结束当前循环,进入下一个 sup
|
||||
// if (/[+\-]/.test(textContent)) {
|
||||
// return; // 结束当前循环,进入下一个 sup
|
||||
// }
|
||||
|
||||
var isSign = /[+\--—]/.test(textContent);
|
||||
|
||||
if (isSign) {
|
||||
return; // 只要是这类符号,直接跳过不染色
|
||||
}
|
||||
|
||||
// 2. 检查邻居(防止离子里的数字被误伤)
|
||||
// 同时也检查邻居是否有这些全角/半角的正负号
|
||||
var prevText = $this.prev('sup').text().trim();
|
||||
var nextText = $this.next('sup').text().trim();
|
||||
var hasSignNeighbor = /[+\--—]/.test(prevText) || /[+\--—]/.test(nextText);
|
||||
|
||||
if (hasSignNeighbor && /^\d+$/.test(textContent)) {
|
||||
return; // 邻居是正负号,判定为离子价态,放行
|
||||
}
|
||||
// 判断文本是否是纯数字
|
||||
if (/^\d+$/.test(textContent)) {
|
||||
|
||||
Reference in New Issue
Block a user