[ BUG ] TOC entry text keeps the HTML of links, images and formatting in a heading

Aperta Adatta ai principianti
#99 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
83/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend

Direzione di ricerca

La issue indica internal/utils/utils.go e internal/adapters/tocgrabber_re.go; inizia leggendo Utils.RemoveStuff e RegexpExtractor.Extract, poi confronta l’output grezzo dell’URL con gli esempi previsti. Il lavoro è completato quando il testo delle voci del TOC rimuove i tag HTML mantenendone il testo interno e le entità già renderizzate, senza modificare gli anchor. Secondo la issue, il percorso dell’URL del blob non è interessato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

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 &amp; Jerry &lt;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 &amp; Jerry &lt;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 in RegexpExtractor.Extract
    (internal/adapters/tocgrabber_re.go).
  • The blob URL of the same file is not affected: its text comes from the JSON payload
    (JSONExtractor).
Lingua principale
Go
Stelle
525
Fork
89
Merge medio
6m
PR unite (30g)
1

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ekalinin/github-markdown-toc.go

Tutte le issue di ekalinin/github-markdown-toc.go

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.