上标离子不变色
This commit is contained in:
@@ -1965,11 +1965,28 @@ function initArticleHtml(htmlData, refs, type, otherList) {
|
|||||||
nextParagraph.style.color = commonSupColor;
|
nextParagraph.style.color = commonSupColor;
|
||||||
}
|
}
|
||||||
$('.wen_rong .content-box .conthtmn sup').each(function () {
|
$('.wen_rong .content-box .conthtmn sup').each(function () {
|
||||||
|
var $this = $(this);
|
||||||
var textContent = $(this).text().trim(); // 获取并清理文本内容
|
var textContent = $(this).text().trim(); // 获取并清理文本内容
|
||||||
|
|
||||||
// 如果包含 + 或 - (离子的特征),直接跳过,不执行后面的标蓝逻辑
|
// 如果包含 + 或 - (离子的特征),直接跳过,不执行后面的标蓝逻辑
|
||||||
if (/[+\-]/.test(textContent)) {
|
// if (/[+\-]/.test(textContent)) {
|
||||||
return; // 结束当前循环,进入下一个 sup
|
// 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)) {
|
if (/^\d+$/.test(textContent)) {
|
||||||
@@ -2484,7 +2501,7 @@ function showComments(num) {
|
|||||||
, btnAlign: 'c'
|
, btnAlign: 'c'
|
||||||
, moveType: 1 //拖拽模式,0或者1
|
, moveType: 1 //拖拽模式,0或者1
|
||||||
, content: shenCode[num],
|
, content: shenCode[num],
|
||||||
success: function(layero, index) {
|
success: function (layero, index) {
|
||||||
// success 会在弹窗 DOM 准备就绪后立即触发
|
// success 会在弹窗 DOM 准备就绪后立即触发
|
||||||
const wmathElements = layero[0].querySelectorAll('wmath');
|
const wmathElements = layero[0].querySelectorAll('wmath');
|
||||||
wmathElements.forEach(el => {
|
wmathElements.forEach(el => {
|
||||||
|
|||||||
Reference in New Issue
Block a user