[ BUG ] TOC entry text keeps the HTML of links, images and formatting in a heading
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 83/100
Research direction
The issue points to internal/utils/utils.go and internal/adapters/tocgrabber_re.go; start by reading Utils.RemoveStuff and RegexpExtractor.Extract, then compare the raw URL output with the expected examples. Done means TOC entry text strips HTML tags while keeping their inner text and the existing rendered entities, without changing the anchors. The blob URL path is unaffected according to the issue.
Written by the indexing model from the issue text.
Description
Describe the bug
For a local file, STDIN or a raw URL, the text of a TOC entry is the HTML that GitHub
renders for the heading, with only <code> removed. A heading with a link, an image,
emphasis or inline HTML gives an entry with tags in its text. The anchors are correct.
The Bash version had the same bug (ekalinin/github-markdown-toc#40,
ekalinin/github-markdown-toc#67) and fixed it in ekalinin/github-markdown-toc#185.
To Reproduce
The test file of the Bash version:
gh-md-toc --hide-header --hide-footer "https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/tests/test%20directory/test_headingmarkup.md"
Actual:
* [Top](#top)
* [On <sub><sub><a href="\#top">Go to Top</a></sub></sub>](#on-go-to-top)
* [<a href="https://github\.com/ekalinin/github\-markdown\-toc/issues/67">My issue</a>](#my-issue)
* [See <a href="\#top">docs</a> here](#see-docs-here)
* [Linux vs\. Samba <em><strong>permissions</strong></em>](#linux-vs-samba-permissions)
* [A <a target="\_blank" rel="noopener noreferrer" href="x\.png"><img src="x\.png" alt="img" style="max\-width: 100%;"></a> B](#a--b)
* [Tom & Jerry <3](#tom--jerry-3)
Expected behavior
All HTML tags are removed, the text inside them is kept, and HTML entities stay as GitHub
renders them, as in the Bash version:
* [Top](#top)
* [On Go to Top](#on-go-to-top)
* [My issue](#my-issue)
* [See docs here](#see-docs-here)
* [Linux vs\. Samba permissions](#linux-vs-samba-permissions)
* [A B](#a--b)
* [Tom & Jerry <3](#tom--jerry-3)
Environment (please complete the following information):
- OS: macOS (darwin/arm64)
- Version: 2.0.1, current
master(dd680f7)
Additional context
utils.RemoveStuff(internal/utils/utils.go) removes only<code>and</code>. It
is applied to the heading text inRegexpExtractor.Extract
(internal/adapters/tocgrabber_re.go).- The blob URL of the same file is not affected: its text comes from the JSON payload
(JSONExtractor).
- Dominant language
- Go
- Stars
- 525
- Forks
- 89
- Avg merge
- 6m
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ekalinin/github-markdown-toc.go
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
All issues in ekalinin/github-markdown-toc.go
Similar issues
-
book-layout.spec fails when the similar-books rail holds other projects' booksPossibly taken @praetorianer777 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
praetorianer777/GoTome#373 ·
Maintainers usually reply within 1 day
-
/shutdown/ready can fail to return an HTTP response when readiness takes longer than the server write timeoutPossibly taken @floriankoch claimed this today. Opentriage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
envoyproxy/gateway#10562 ·
Maintainers usually reply within 1 day
-
Adding an LDAP group reports every search failure as "LDAP Group DN is not found"Possibly taken @Daksha1611 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100