Skip to content

Commit

Permalink
🎨 Vditor 支持
Browse files Browse the repository at this point in the history
图片使用引用风格时的解析问题
Vanessa219/vditor#684
  • Loading branch information
88250 committed Aug 7, 2020
1 parent fa2fdcf commit 58b0507
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
35 changes: 12 additions & 23 deletions javascript/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions render/vditor_sv_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,17 @@ func (r *VditorSVRenderer) renderBang(node *ast.Node, entering bool) ast.WalkSta
}

func (r *VditorSVRenderer) renderImage(node *ast.Node, entering bool) ast.WalkStatus {
if entering {
if 3 == node.LinkType {
node.ChildByType(ast.NodeOpenParen).Unlink()
node.ChildByType(ast.NodeLinkDest).Unlink()
if linkSpace := node.ChildByType(ast.NodeLinkSpace); nil != linkSpace {
linkSpace.Unlink()
node.ChildByType(ast.NodeLinkTitle).Unlink()
}
node.ChildByType(ast.NodeCloseParen).Unlink()
}
}
return ast.WalkContinue
}

Expand Down
1 change: 1 addition & 0 deletions test/spinv_sv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

var spinVditorSVDOMTests = []*parseTest{

{"61", "![text][foo]\n\n[foo]: bar", "<span data-type=\"text\" class=\"h1\">foo</span><span data-type=\"newline\" class=\"h1\"><br/><span style=\"display: none\">\n</span></span><span data-type=\"text\" class=\"h1\"><wbr></span><span data-type=\"newline\" class=\"h1\"><br/><span style=\"display: none\">\n</span></span><span class=\"vditor-sv__marker--heading h1\" data-type=\"heading-marker\">===</span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span>"},
{"60", "foo\n\n===", "<span data-type=\"text\" class=\"h1\">foo</span><span data-type=\"newline\" class=\"h1\"><br/><span style=\"display: none\">\n</span></span><span data-type=\"text\" class=\"h1\"><wbr></span><span data-type=\"newline\" class=\"h1\"><br/><span style=\"display: none\">\n</span></span><span class=\"vditor-sv__marker--heading h1\" data-type=\"heading-marker\">===</span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span>"},
{"59", "foo\n‸--", "<span data-type=\"text\" class=\"h2\">foo<wbr></span><span data-type=\"newline\" class=\"h2\"><br/><span style=\"display: none\">\n</span></span><span class=\"vditor-sv__marker--heading h2\" data-type=\"heading-marker\">---</span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span>"},
{"58", "---‸", "<span data-type=\"yaml-front-matter-open-marker\" class=\"vditor-sv__marker\">---</span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span><span data-type=\"text\"><wbr></span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span><span data-type=\"yaml-front-matter-close-marker\" class=\"vditor-sv__marker\">---</span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span><span data-type=\"newline\"><br /><span style=\"display: none\">\n</span></span>"},
Expand Down

0 comments on commit 58b0507

Please sign in to comment.