Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Links with nested HTML or \n confuse the markdown converter

Aperta
#53 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
tooling

Direzione di ricerca

L'issue non indica file né test. Inizia riproducendo i tre casi di link HTML riportati nel report nel convertitore Markdown, quindi esamina la corrispondenza del testo dell'ancora e la gestione di node textContent descritte lì. Il lavoro è completo quando gli elementi annidati e le interruzioni di riga nei link producono i link Markdown previsti, con una copertura di regressione per gli esempi segnalati.

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

Descrizione

A couple cases that generate the wrong markup.

1. nested html elements in link
<a href="http://example.com/"><span>foo</span></a> <a href="http://example.com/">bar</a> foo bar

gets converted to

[foo](http://example.com/) bar foo [bar](http://example.com/)

when I would expect

[foo](http://example.com/) [bar](http://example.com/) foo bar

What happens: the walker enters the a and then enters the span again, finding the same text twice. But the proper label text was already consumed, so it consumes until it finds another match. In some cases (like above) it even linkifies the wrong text.

2. line breaks in link
<a href="https://example.com/">foo
bar</a>

(notice the line break) gets converted to

foo bar

when I would expect

[foo bar](https://example.com/)

What happens: the node textContent is 'foo\nbar' which doesn't match any text in the plaintext.

2b. <br> in link

Another similar (but possibly harder to fix) case is

<a href="https://example.com/">foo<br>bar</a>

which like 2 doesn't create a link:

foo
bar

In general, since the code can't rely on the browser to properly deal with HTML content, some of these corner cases will probably keep popping up. But this happened in the real world (try copying and pasting the first news entry in the deprecated section here) and it seemed to be significant enough to report.

I will follow up with a PR that suggests potential fixes for 1 and 2 (but not 2b), but this is not my field so it might be far from good.

Lingua principale
JavaScript
Stelle
234
Fork
47
Merge medio
1g 12h
PR unite (30g)
5

Guida per i contributori

Apri la 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 github/paste-markdown

Tutte le issue di github/paste-markdown

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.