[ BUG ] Headings are missing from the TOC when GitHub puts a line break after the heading tag
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
issueで選択した行を見出しのgrepの前に結合すると説明されている、gh-md-toc の gh_toc_grab から始めます。提供された test.md の例を使って再現し、ローカルファイルとstdinの両方で、リンクまたはインラインコードを含む見出しがTOCに含まれることを確認します。期待される3つの項目が順番どおりに表示されれば完了です。
索引モデルが 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分
- マージ済み PR(30日)
- 21
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 ·