Links with nested HTML or \n confuse the markdown converter
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- tooling
Research direction
The issue names no files or tests. Start by reproducing the three HTML-link cases from the report in the markdown converter, then inspect the anchor-text matching and node textContent handling described there. Done means nested elements and line breaks in links produce the expected Markdown links, with regression coverage for the reported examples.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- JavaScript
- Stars
- 234
- Forks
- 47
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 5
Contributor 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 github/paste-markdown
-
Pasting a link whose text/html label is a shortened form of its URL plants a `[` inside the URL Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
github/paste-markdown#118 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
github/paste-markdown#107 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
github/paste-markdown#104 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
github/paste-markdown#100 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
github/paste-markdown#96 · 1 comment ·
All issues in github/paste-markdown
Similar issues
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AllTheMods/ATM-10-L#19 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SignalK/n2k-signalk#345 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
JuliaPluto/PlutoPlotly.jl#72 ·