Links with nested HTML or \n confuse the markdown converter
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- tooling
Línea de trabajo
El issue no menciona archivos ni pruebas. Empieza reproduciendo los tres casos de enlaces HTML del informe en el conversor de Markdown y, después, inspecciona la coincidencia del texto del ancla y el manejo de node textContent que se describen allí. Se considera terminado cuando los elementos anidados y los saltos de línea en los enlaces producen los enlaces Markdown esperados, con cobertura de regresión para los ejemplos indicados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 234
- Forks
- 47
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 5
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/paste-markdown
-
Pasting a link whose text/html label is a shortened form of its URL plants a `[` inside the URL Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
github/paste-markdown#118 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
github/paste-markdown#107 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
github/paste-markdown#104 ·
-
Examples page is broken Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
github/paste-markdown#100 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
github/paste-markdown#96 · 1 comentario ·
Todos los issues de github/paste-markdown
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
palladius/rails8-app-on-gcp#145 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotenvx/dotenv-vscode#139 ·
-
test-change-proposal
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
web-platform-tests/interop#1455 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
corsairdev/corsair#1764 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100