Skip to content

Commit

Permalink
✨ Vditor 所见即所得模式支持链接引用定义 Vanessa219/vditor#55
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Mar 7, 2020
1 parent c53da05 commit ba2aca0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion 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.

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

var md2VditorTests = []parseTest{

{"11", "[foo][1]\n\n[1]: /bar\n", "<p data-block=\"0\"><span data-type=\"link-ref\" data-link-text=\"foo\" data-link-label=\"1\">foo</span>\n</p><p data-block=\"0\" data-type=\"link-ref-defs\">[1]: /bar\n</p>"},
{"10", "Foo\n ---\n", "<p data-block=\"0\">Foo\n---\n</p>"},
{"9", " ***\n ***\n\n- - - -", "<div class=\"vditor-wysiwyg__block\" data-type=\"code-block\" data-block=\"0\" data-marker=\"***\n ***\n\"><pre><code>***\n ***\n</code></pre></div><hr data-block=\"0\" />"},
{"8", " ***\n", "<div class=\"vditor-wysiwyg__block\" data-type=\"code-block\" data-block=\"0\" data-marker=\"***\n\"><pre><code>***\n</code></pre></div>"},
Expand Down
2 changes: 1 addition & 1 deletion test/spinv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

var spinVditorDOMTests = []*parseTest{

{"105", "<p data-block=\"0\">[1]</p><p data-block=\"0\" data-type=\"linkRefDefs\">[1]: f<wbr>\n</p>", "<p data-block=\"0\"><a href=\"\"baz\"\">foo</a>\n</p>"},
{"105", "<p data-block=\"0\">[1]</p><p data-block=\"0\" data-type=\"linkRefDefs\">[1]: f<wbr>\n</p>", "<p data-block=\"0\"><span data-type=\"link-ref\" data-link-text=\"1\" data-link-label=\"1\">1</span>\n</p><p data-block=\"0\" data-type=\"link-ref-defs\">[1]: f<wbr>\n</p>"},
{"104", "<a href=\"\" title=\"baz\">foo</a>", "<p data-block=\"0\"><a href=\"\"baz\"\">foo</a>\n</p>"},
{"103", "<p data-block=\"0\"><strong data-marker=\"**\">foo\n<em data-marker=\"*\">ba<wbr></em></strong>\n</p>", "<p data-block=\"0\"><strong data-marker=\"**\">foo\n<em data-marker=\"*\">ba<wbr></em></strong>\n</p>"},
{"102", "<p data-block=\"0\"><strong data-marker=\"**\">foo<em>\u200b\nb<wbr></em></strong>\n</p>", "<p data-block=\"0\"><strong data-marker=\"**\">foo\n<em data-marker=\"*\">b<wbr></em></strong>\n</p>"},
Expand Down
9 changes: 2 additions & 7 deletions vditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,13 +804,8 @@ func (lute *Lute) genASTByVditorDOM(n *html.Node, tree *parse.Tree) {
node.Tokens = codeTokens
tree.Context.Tip.AppendChild(node)
} else if "link-ref" == dataType {
node.Type = ast.NodeLink
node.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
node.AppendChild(&ast.Node{Type: ast.NodeLinkText, Tokens: []byte(lute.domAttrValue(n, "link-text"))})
node.AppendChild(&ast.Node{Type: ast.NodeCloseBracket})
node.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
node.AppendChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(lute.domAttrValue(n, "link-label"))})
node.AppendChild(&ast.Node{Type: ast.NodeCloseBracket})
node.Type = ast.NodeText
node.Tokens = []byte("[" + lute.domAttrValue(n, "link-text") + "][" + lute.domAttrValue(n, "link-label") + "]")
tree.Context.Tip.AppendChild(node)
}
return
Expand Down

0 comments on commit ba2aca0

Please sign in to comment.