Repository navigation
fix(counter): scope heading counters and fix cascading resets - #2
Merged
Merged
Conversation
taoky
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复
src/templates/assets/stylesheets/ustclug/_counter.scss中全局标题自动编号的两处问题:全局裸
h1–h6选择器误伤非正文大纲标题并污染外部计数器Linux101-docs的Appendix/markdown.md中,提示框(.admonition)内用于演示效果的<h1>/<h2>/<h6>会被自动加上2 this is H2、2.1.0.0.1 this is H6等编号,并把提示框后原本的1.2 段落顶成2.2 段落。.md-search-result__article)也会用<h2>渲染小节结果,同样会被裸h2::before加上无关编号。.md-content__inner > h1~h6(并在.md-content__inner上初始化计数器),仅对正文容器直接子标题编号。跳级标题下计数器不自增(卡死在
.0.1)h2只counter-reset: h3),且把counter-increment写在::before伪元素上。当页面跳过某级标题(例如h2后直接接多个h4,如Linux101-docs原Spec/slide.md)时,外层作用域不存在h4计数器,每个h4::before都会临时创建仅作用于该伪元素的h4=1,导致连续多个h4全都显示为1.0.1。counter-increment移回标题元素本身,并让各级标题级联重置所有更低级计数器(如> h2 { counter-reset: h3 h4 h5 h6; counter-increment: h2; })。构建产物说明:
FORK.md运行npm run build:all重新生成material/。0a541db(Merge upstream tag 9.8.1)合入上游e325895升级后的构建依赖时未全量重编material/,本次完整构建顺带刷新了palette、bundle、custom的产物 hash(iconsearch_index.json内容与HEAD一致,无变更)。本地验证:
npm test(11/11)、npm run check(tsc/stylelint/eslint)、npm run build:all均通过。Linux101-docs中预览确认:/Appendix/markdown/示例框不再带编号且后续恢复1.2 段落,搜索下拉结果的小节标题也不再带假编号。问题排查、修改与本地验证使用了 Google Antigravity(Gemini 模型)辅助,所有改动均已人工核对并在本地浏览器确认效果。