Links with nested HTML or \n confuse the markdown converter
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- tooling
调研方向
该 issue 没有列出文件或测试。首先在 Markdown 转换器中复现报告中的三个 HTML 链接案例,然后检查其中描述的锚文本匹配和 node textContent 处理。完成的标准是:链接中的嵌套元素和换行能够生成预期的 Markdown 链接,并为报告中的示例提供回归覆盖。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- JavaScript
- 星标
- 234
- 派生
- 47
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 5
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/paste-markdown 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
github/paste-markdown#118 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
github/paste-markdown#107 ·
-
难度 2/5 1-3 小时 新手友好度 45/100
github/paste-markdown#104 ·
-
难度 3/5 1-2 天 新手友好度 35/100
github/paste-markdown#100 ·
-
难度 3/5 1-2 天 新手友好度 48/100
github/paste-markdown#96 · 1 条评论 ·
查看 github/paste-markdown 的全部 Issue
相似的 Issue
-
bug confirmed issue
难度 2/5 1-3 小时 新手友好度 75/100
open-webui/open-webui#30750 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
Mend: dependency security vulnerability untriaged
难度 2/5 1-3 小时 新手友好度 70/100