[ BUG ] Headings are missing from the TOC when GitHub puts a line break after the heading tag
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
调研方向
从 gh-md-toc 中的 gh_toc_grab 开始。issue 指出,它会先连接选中的行,再用 grep 搜索标题。使用提供的 test.md 示例复现问题,然后检查本地文件和 stdin 输入的 TOC 中是否都包含带链接或行内代码的标题。预期的三个条目按顺序出现即为完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Some headings are missing from the TOC, without any warning. For these headings the HTML from GitHub has a line break right after the opening heading tag:
<div class="markdown-heading"><h2 class="heading-element">
<a href="https://example.com" rel="nofollow">link</a> here</h2><a id="user-content-link-here" class="anchor" aria-label="Permalink: link here" href="#link-here"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
gh_toc_grab joins a line with the next one only when the next one starts with </h or <span. So <h2 class="heading-element"> stays on its own line, the heading text and the anchor are on the next line, and grep '<h[1-6][^>]*class="heading-element".*</a' does not find the heading.
To Reproduce
cat > test.md <<'MD'
# Top
## [link](https://example.com) here
## `"q'` and *em*
## Last
MD
./gh-md-toc test.md
Output:
Table of Contents
=================
* [Top](#top)
* [Last](#last)
The HTML from https://api.github.com/markdown/raw for the two missing headings:
<div class="markdown-heading"><h2 class="heading-element">
<a href="https://example.com" rel="nofollow">link</a> here</h2><a id="user-content-link-here" class="anchor" aria-label="Permalink: link here" href="#link-here"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<div class="markdown-heading"><h2 class="heading-element">
<code>"q'</code> and <em>em</em>
</h2><a id="user-content-q-and-em" class="anchor" aria-label="Permalink: "q' and em" href="#q-and-em"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
cat test.md | ./gh-md-toc - gives the same two entries.
Expected behavior
* [Top](#top)
* [link here](#link-here)
* ["q' and em](#q-and-em)
* [Last](#last)
Environment (please complete the following information):
- OS: macOS (Darwin 24.6.0)
- Version: 0.11.0 (master at 34828c5)
Additional context
Found while looking into #153: a heading that starts with inline code can be missing too. Checked with a local file and stdin, not with a remote URL.
- 主要语言
- 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 小时 新手友好度 82/100
ekalinin/github-markdown-toc#204 ·
维护者通常 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 ·