[ 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 ·