Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

readme_toc.py generates duplicate fragment links for repeated headings

オープン 初心者向け
#57,719 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@akhil9tiet がすでに取り組んでいます。

2026年10月28日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
markdown, python
領域
tooling

調査の方向性

まず scripts/readme_toc.py を確認し、generate_toc_lines を調べてから、issue に記載された対象の回帰ケースを実行してください。見出しの重複と、同じフラグメントに正規化される異なるタイトルのケースを追加してください。生成されるアンカーが一意で、見出しの重複に対して期待される数値サフィックスを使う状態が完了の基準です。

索引モデルが issue の本文から書いたものです。

説明

bug

Summary

scripts/readme_toc.py generates the same fragment for repeated Markdown headings. GitHub assigns unique heading anchors (#setup, #setup-1, ...), so the second and later entries in a generated table of contents navigate to the first heading instead.

Minimal reproduction

On current main (inspected commit e742db9f7ba98e63e502b310857d49d047888518), run the existing helper:

from scripts.readme_toc import generate_toc_lines

print(generate_toc_lines("## Setup\n\n## Setup\n"))

Actual:

['- [Setup](#setup)', '- [Setup](#setup)']

Expected:

['- [Setup](#setup)', '- [Setup](#setup-1)']

Impact

When --fix writes a ToC for a Markdown document with repeated section titles, later entries silently point at the wrong section. The check mode can then accept that incorrect ToC because it compares against the same generator.

Validation

  • Reproduced by executing the generate_toc_lines implementation from the current source in an isolated Python environment.
  • A focused unittest asserting unique links for two ## Setup headings fails: 1 test, 1 failure, with the second generated fragment #setup instead of #setup-1.
  • This is a source-level / isolated regression test; no full repository test suite or GitHub renderer integration test was run.

Suggested fix

Track collisions of the normalized fragment, assign numeric suffixes matching GitHub heading-anchor behavior, and add regression cases for two and three repeated headings (including collisions between different raw titles that normalize to the same fragment).

Related reports checked

I checked issue/PR searches for readme_toc.py, toc, and duplicate heading/anchor wording. Existing issue #41077 concerns fenced-code parsing, not duplicate heading IDs. This report is intentionally separate.

Source: https://github.com/openai/codex/blob/e742db9f7ba98e63e502b310857d49d047888518/scripts/readme_toc.py

主要言語
Rust
スター
131k
フォーク
20.7k
平均マージ
1分
マージ済み PR(30日)
997

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openai/codex のほかの issue

openai/codex の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。