[ BUG ] TOC entries have no text on OS/390
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 gh-md-toc 开始,在 gh_toc_grab 的 OS/390 分支中找到约第 428 行,并将其标题文本提取方式与默认分支中更新后的表达式进行比较。Issue 中包含一个会强制进入此分支的 macOS 复现步骤;运行它以确认 TOC 标签为空,然后检查两个标题是否都生成了预期的文本和锚点。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
On OS/390 (z/OS) every TOC entry has an empty text: * [](#title) instead of * [Title](#title).
The OS/390 branch of gh_toc_grab takes the heading text with an expression for the old GitHub HTML layout (line 428 on master at a28f86d):
text = substr($0, match($0, /<\/span><\/a>[^<]*<\/h/)+11, RLENGTH-14)
In the old layout the anchor was inside the heading tag, before the text. Now it comes after the heading tag, and the line ends at </a (the grep pattern <h[1-6][^>]*class="heading-element".*</a):
<h1 class="heading-element">gh-md-toc</h1><a id="user-content-gh-md-toc" class="anchor" aria-label="Permalink: gh-md-toc" href="#gh-md-toc"><span aria-hidden="true" class="octicon octicon-link"></span></a
There is no </span></a> followed by the text and </h, so match returns 0 and text is empty. The link is fine: since #185 both branches take it from the class="anchor" element.
7d0a86b ("Update for a new GH HTML layout") changed the grep pattern and the text expression of the default branch to the new layout, but not the text expression of the OS/390 branch.
To Reproduce
Not run on z/OS. Simulated on macOS with a copy of gh-md-toc where the OS/390 branch of gh_toc_grab is always taken, and pcregrep -o is replaced with grep -Eo (the same pattern):
sed -e '422s/if \[ "$(uname -s)" == "OS\/390" \]; then/if true; then/' \
-e '423s/grepcmd="pcregrep -o"/grepcmd="grep -Eo"/' gh-md-toc > os390-gh-md-toc
chmod +x os390-gh-md-toc
printf '# Title\n\n## Section\n' > test.md
./os390-gh-md-toc test.md
Output:
Table of Contents
=================
* [](#title)
* [](#section)
For README.md of this repository, all 17 entries have an empty text.
Expected behavior
* [Title](#title)
* [Section](#section)
Environment (please complete the following information):
- OS: OS/390 (simulated on macOS, Darwin 24.6.0)
- Version: 0.11.0 (master at a28f86d)
Additional context
Found while working on #153 (#202).
- 主要语言
- Shell
- 星标
- 3.3k
- 派生
- 2.7k
- 平均合并
- 1 小时 56 分钟
- 30 天内合并 PR
- 21
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ekalinin/github-markdown-toc 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
ekalinin/github-markdown-toc#201 ·
维护者通常 1 天内回复
-
enhancement
难度 1/5 1-3 小时 新手友好度 78/100
ekalinin/github-markdown-toc#176 ·
维护者通常 1 天内回复
-
Update outdated examples and versions in README可能已有人在做 @SatvikMishra08 于 42 天前认领。 未关闭documentation
难度 2/5 1-3 小时 新手友好度 88/100
ekalinin/github-markdown-toc#165 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 76/100
ekalinin/github-markdown-toc#203 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 70/100
ekalinin/github-markdown-toc#194 ·
维护者通常 1 天内回复
查看 ekalinin/github-markdown-toc 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
msys2/MINGW-packages#33356 · 1 条评论 ·
维护者通常 1 天内回复
-
Misleading 'Update → Config → Hyprland' menu item silently resets user configs without confirmation未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 78/100
kunchenguid/headless#23 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
mack-a/v2ray-agent#1370 ·