Skip to content

Commit

Permalink
🐛 <a> 中嵌套 <img> 时,整个 <a> 被过滤 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluishoul authored Sep 26, 2021
1 parent 8370687 commit 7f3946a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions test/v2m_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (

var vditorDOM2MdTests = []parseTest{

{"117", "<a><img></a>", "[![]()]()\n"},
{"116", "<a href=\"https://example.com\"><img src=\"https://example.org\" alt=\"example\" title=\"example\"></a>", "[![example](https://example.org \"example\")](https://example.com)\n"},
{"115", "<ul><li><img src=\"xxx.png\"></li></ul>", "* ![](xxx.png)\n"},
{"114", "<p data-block=\"0\"><span class=\"vditor-comment vditor-comment--focus\" data-cmtids=\"20201105103606-fpmdc18\">foo<wbr></span></p>", "<span class=\"vditor-comment vditor-comment--focus\" data-cmtids=\"20201105103606-fpmdc18\">foo</span>\n"},
{"113", "<div data-block=\"0\" data-type=\"footnotes-block\"><p><wbr><br></p></div>", "\n"},
Expand Down
8 changes: 5 additions & 3 deletions vditor_wysiwyg.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,9 +998,11 @@ func (lute *Lute) genASTByVditorDOM(n *html.Node, tree *parse.Tree) {
tree.Context.Tip = node
defer tree.Context.ParentTip()
case atom.A:
text := lute.domText(n)
if "" == text || parse.Zwsp == text {
return
if n.FirstChild == nil || n.FirstChild.Type == html.TextNode {
text := lute.domText(n)
if "" == text || parse.Zwsp == text {
return
}
}

node.Type = ast.NodeLink
Expand Down

0 comments on commit 7f3946a

Please sign in to comment.