标题提取空过滤 样式修改

This commit is contained in:
2025-07-18 15:15:13 +08:00
parent 914bf6adc6
commit abed0283c8
2 changed files with 20 additions and 13 deletions

View File

@@ -121,21 +121,27 @@
// 内容
// 清空标题列表
$("#title-list ul").empty();
// 提取 h1 标题
// 提取 h3 标题
var h1Titles = $("#rendered-content").find("h3");
h1Titles.each(function (index) {
var title = $(this);
var titleText = title.text();
var titleId = "title-" + index;
title.attr("id", titleId);
var listItem = $("<li>");
var link = $("<a>", {
href: "#" + titleId,
text: titleText
// 只有当找到h3标题且内容不为空时才进行处理
if (h1Titles.length > 0) {
h1Titles.each(function (index) {
var title = $(this);
var titleText = title.text().trim(); // 使用trim()去除空白字符
// 只有当标题文本不为空时才添加到列表
if (titleText) {
var titleId = "title-" + index;
title.attr("id", titleId);
var listItem = $("<li>");
var link = $("<a>", {
href: "#" + titleId,
text: titleText
});
listItem.append(link);
$("#title-list ul").append(listItem);
}
});
listItem.append(link);
$("#title-list ul").append(listItem);
});
}
});
</script>
{/block}

View File

@@ -173,6 +173,7 @@
.narshelpdetailPc .nars-help-content .nars-hlpdt-ml .sub-list li a.active {
color: #1f2635;
border-bottom: 1px solid #1f2635;
font-weight: bold;
}
.narshelpdetailPc .nars-help-content .nars-hlpdt-mm {