[ BUG ] Backslash sequences in heading text are interpreted by echo -e
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
- 76/100
Hướng nghiên cứu
Start at gh_toc_grab around line 470, where the generated TOC passes through echo -e, and trace how the href escapes are produced by the awk script. Reproduce with the supplied headings containing \n and \c, then check that the generated TOC preserves those backslashes and retains later entries. Verify both normal output and --insert --no-backup --hide-footer.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
A backslash sequence in the heading text, such as \n or \c, is interpreted in the TOC entry. \n splits the entry into two lines, and \c cuts the TOC: the rest of that entry and all the entries after it are lost.
gh_toc_grab prints the TOC with echo -e (line 470 on master at a28f86d):
echo $echoargs "$(awk ... "$awkscript")"
-e is there for the link: awk turns every % of the href into \x, and echo -e decodes the \xNN sequences, see #6 and #10. But the whole line goes through it, so the heading text does too. The OS/390 branch sets echoargs="", so it is not affected.
To Reproduce
cat > test.md <<'MD'
# Top
## The `\n` escape
## Use \c to stop
## Last
MD
./gh-md-toc test.md
Output:
Table of Contents
=================
* [Top](#top)
* [The
escape](#the-n-escape)
* [Use
<!-- Created by https://github.com/ekalinin/github-markdown-toc -->
GitHub renders these headings as The <code>\n</code> escape, Use \c to stop and Last, so the backslashes come into gh_toc_grab as they are.
--insert --no-backup --hide-footer writes the same broken TOC into the file, with exit code 0:
<!--ts-->
* [Top](#top)
* [The
escape](#the-n-escape)
* [Use
<!--te-->
Expected behavior
* [Top](#top)
* [The \n escape](#the-n-escape)
* [Use \c to stop](#use-c-to-stop)
* [Last](#last)
Environment (please complete the following information):
- OS: macOS (Darwin 24.6.0), GNU bash 5.3.15
- Version: 0.11.0 (master at a28f86d)
Additional context
Found while working on #153: headings with inline code, such as `\n`, are more likely to have a backslash. It is the same with and without --keep-code from #202.
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ekalinin/github-markdown-toc
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ekalinin/github-markdown-toc#204 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[ BUG ] Headings are missing from the TOC when GitHub puts a line break after the heading tagĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ekalinin/github-markdown-toc#201 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update bats version in CIĐang mởenhancement
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
ekalinin/github-markdown-toc#176 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update outdated examples and versions in READMECó thể đã có người làm @SatvikMishra08 đã nhận 42 ngày trước. Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ekalinin/github-markdown-toc#165 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
ekalinin/github-markdown-toc#194 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ekalinin/github-markdown-toc
Issue tương tự
-
flac's CMake config is brokenĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
msys2/MINGW-packages#33356 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Misleading 'Update → Config → Hyprland' menu item silently resets user configs without confirmationĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kunchenguid/headless#23 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mack-a/v2ray-agent#1370 ·