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

Đang mở
#194 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
70/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bash, markdown, shell
Lĩnh vực
cli, documentation

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Shell
Star
3.3k
Fork
2.7k
Merge trung bình
1 giờ 56 phút
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ekalinin/github-markdown-toc

Tất cả issue của ekalinin/github-markdown-toc

Issue tương tự

Thêm issue về Shell/Bash

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.