Skip to content

Commit 0f97154

Browse files
committed
🐛 VditorIRDOM2Md 公式多出一个换行 Fix #184
1 parent df878c7 commit 0f97154

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

javascript/lute.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/lute.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/v2m_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func TestVditorDOM2Md(t *testing.T) {
153153

154154
var vditorIRDOM2MdTests = []parseTest{
155155

156+
{"12", "<div data-block=\"0\" data-type=\"math-block\" class=\"vditor-ir__node\"><span data-type=\"math-block-open-marker\">$$</span><pre class=\"vditor-ir__marker--pre vditor-ir__marker\"><code data-type=\"math-block\" class=\"language-math\">s_i = P(V | z_i) = f_s(z_i; \\theta^{s})</code></pre><pre class=\"vditor-ir__preview\" data-render=\"2\"><div data-type=\"math-block\" class=\"language-math\">s_i = P(V | z_i) = f_s(z_i; \\theta^{s})</div></pre><span data-type=\"math-block-close-marker\">$$</span></div>", "$$\ns_i = P(V | z_i) = f_s(z_i; \\theta^{s})\n$$\n"},
156157
{"11", "<table data-type=\"table\" data-node-id=\"20201028173434-2i1b4ah\"><thead><tr><th>foo</th></tr></thead><tbody><tr><td>bar *baz*<wbr></td></tr></tbody></table>", "| foo |\n| --------- |\n| bar *baz* |\n"},
157158
{"10", "<ul data-tight=\"true\" data-marker=\"-\"><li data-marker=\"-\" class=\"vditor-task\" data-node-id=\"\"><input checked=\"\" type=\"checkbox\"></li></ul>", "\n"},
158159
{"9", "<ul data-tight=\"true\" data-marker=\"*\"><li data-marker=\"*\">foo<div data-type=\"code-block\" class=\"vditor-ir__node\"><span data-type=\"code-block-open-marker\">```</span><span class=\"vditor-ir__marker vditor-ir__marker--info\" data-type=\"code-block-info\">​</span><pre class=\"vditor-ir__marker--pre vditor-ir__marker\"><code>bar\n</code></pre><pre class=\"vditor-ir__preview\" data-render=\"1\"><div class=\"vditor-copy\"><textarea></textarea><span aria-label=\"复制\" onmouseover=\"this.setAttribute('aria-label', '复制')\" class=\"b3-tooltips b3-tooltips__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 nginx\"><span class=\"hljs-attribute\">bar</span>\n</code></pre><span data-type=\"code-block-close-marker\">```</span></div>ba<wbr></li></ul>", "* foo\n ```\n bar\n ```\n ba\n"},

vditor_ir.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,8 @@ func (lute *Lute) genASTByVditorIRDOM(n *html.Node, tree *parse.Tree) {
392392
divDataType := util.DomAttrValue(n.Parent, "data-type")
393393
switch divDataType {
394394
case "math-block":
395-
node.Type = ast.NodeMathBlock
396-
node.AppendChild(&ast.Node{Type: ast.NodeMathBlockContent, Tokens: codeTokens})
395+
node.Type = ast.NodeMathBlockContent
396+
node.Tokens = codeTokens
397397
tree.Context.Tip.AppendChild(node)
398398
case "html-block":
399399
node.Type = ast.NodeHTMLBlock

0 commit comments

Comments
 (0)