Skip to content

Commit

Permalink
🎨 Vditor 支持 Fix Vanessa219/vditor#173
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Feb 24, 2020
1 parent dfed627 commit 84fa000
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 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.

2 changes: 2 additions & 0 deletions test/v2m_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (

var vditorDOM2MdTests = []parseTest{

{"98", `<ul data-tight="true" data-marker="+" data-block="0"><li data-marker="+"><p>foo</p></li><ul data-tight="true" data-marker="+" data-block="0"><li data-marker="+"><p>bar</p></li></ul><li><p><wbr><br></p></li></ul>`, "+ foo\n + bar\n+\n"},
{"97", `<ol data-tight="true" data-block="0"><li data-marker="1."><p>foo</p></li><ol data-tight="true" data-block="0"><li data-marker="1."><p>bar</p></li></ol><li><p><wbr><br></p></li></ol>`, "1. foo\n 1. bar\n2.\n"},
{"96", "<p data-block=\"0\">\u200b<code marker=\"`\">\u200bcode\nspan<wbr></code>\u200b\n</p>", "`code span`\n"},
{"95", "<p data-block=\"0\"><strong data-marker=\"**\"><wbr></strong>\n</p>", "\n"},
{"94", "<blockquote data-block=\"0\"><ul data-tight=\"true\" data-marker=\"*\" data-block=\"0\"><li data-marker=\"*\">foo<div class=\"vditor-wysiwyg__block\" data-type=\"code-block\" data-block=\"0\" data-marker=\"```\"><pre style=\"display: none;\"><code>code block\n</code></pre><div class=\"vditor-wysiwyg__preview\" data-render=\"false\"><pre><div class=\"vditor-copy\"><textarea></textarea><span aria-label=\"复制\" onmouseover=\"this.setAttribute('aria-label', '复制')\" class=\"vditor-tooltipped vditor-tooltipped__w\" onclick=\"this.previousElementSibling.select();document.execCommand('copy');this.setAttribute('aria-label', '已复制')\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\" width=\"32px\" height=\"32px\"> <path d=\"M28.681 11.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-11.5c-1.379 0-2.5 1.121-2.5 2.5v23c0 1.378 1.121 2.5 2.5 2.5h19c1.378 0 2.5-1.122 2.5-2.5v-15.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 9.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268v0zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-19c-0.271 0-0.5-0.229-0.5-0.5v-23c0-0.271 0.229-0.5 0.5-0.5 0 0 11.499-0 11.5 0v7c0 0.552 0.448 1 1 1h7v15.5zM18.841 1.319c-1.612-1.182-2.393-1.319-2.841-1.319h-11.5c-1.378 0-2.5 1.121-2.5 2.5v23c0 1.207 0.86 2.217 2 2.45v-25.45c0-0.271 0.229-0.5 0.5-0.5h15.215c-0.301-0.248-0.595-0.477-0.873-0.681z\"></path> </svg></span></div><code class=\"hljs properties\" style=\"max-height: 1000px;\"><span class=\"hljs-attr\">code</span> <span class=\"hljs-string\">block</span></code></pre></div></div></li></ul><p><wbr><br></p></blockquote>", "> * foo\n> ```\n> code block\n> ```\n"},
Expand Down
8 changes: 6 additions & 2 deletions vditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,14 @@ func (lute *Lute) genASTByVditorDOM(n *html.Node, tree *parse.Tree) {
var bullet byte
if "" == marker {
if atom.Ol == n.Parent.DataAtom {
firstLiMarker := lute.domAttrValue(n.Parent.FirstChild, "data-marker")
if startAttr := lute.domAttrValue(n.Parent, "start"); "" == startAttr {
marker = "1."
marker = "1"
} else {
marker = startAttr + "."
marker = startAttr
}
if "" != firstLiMarker {
marker += firstLiMarker[len(firstLiMarker) -1:]
}
} else {
marker = lute.domAttrValue(n.Parent, "data-marker")
Expand Down

0 comments on commit 84fa000

Please sign in to comment.