[ BUG ] --insert and --stdout fill every <!--ts--> / <!--te--> pair, also in code blocks

オープン
#194 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

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

調査の方向性

Start with the marker check and the two sed edits described in the issue, then reproduce the behavior with the provided test.md example and --stdout. Compare the output with the expected behavior: marker pairs inside fenced code blocks should remain unchanged. Check --insert --no-backup on a copy of the README as well; done means both modes update the intended TOC while preserving the examples.

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

説明

bug

Describe the bug

--insert and --stdout put the TOC between every <!--ts--> / <!--te--> pair in the file. Marker lines inside fenced code blocks count too, so examples that show the markers are overwritten.

The marker check (grep -Fxq "<!--ts-->") only tests that a marker line exists. The edit (sed "/<\!--ts-->/,/<\!--te-->/{//!d;}", then sed "/<\!--ts-->/r ...") runs on every line that has a marker.

To Reproduce

printf '<!--ts-->\n<!--te-->\n\n# Title\n\nPut these lines into a file:\n\n```\n<!--ts-->\n<!--te-->\n```\n' > test.md
./gh-md-toc --hide-footer --stdout test.md

Output:

<!--ts-->
* [Title](#title)
<!--te-->

# Title

Put these lines into a file:

```
<!--ts-->
* [Title](#title)
<!--te-->
```

The README of this repository has three pairs: the TOC (lines 31-47) and two examples in code blocks of the "Auto insert and update TOC" section (lines 318-319 and 353-369). ./gh-md-toc --hide-footer --stdout README.md puts the TOC into all three:

  • the example "Just put into a file these two lines" gets the whole TOC between its two lines;
  • the example output of grep -A15 "<\!\-\-ts" README.test.md is replaced with the TOC of README.md.

--insert --no-backup --hide-footer on a copy of README.md gives the same file as --stdout.

Expected behavior

The examples in code blocks stay unchanged.

Environment (please complete the following information):

  • OS: macOS (Darwin 24.6.0)
  • Version: 0.11.0 (master at 62e6fe4)

Additional context

Found while looking into #119.

主要言語
Shell
スター
3.3k
フォーク
2.7k
平均マージ
1時間 56分
マージ済み PR(30日)
21

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

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

ekalinin/github-markdown-toc のほかの issue

ekalinin/github-markdown-toc の issue をすべて見る

似ている issue

Shell/Bash の issue をもっと見る

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

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