Skip to content

Commit

Permalink
✨ 支持 kramdown 内联属性列表 #89
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 15, 2020
1 parent b3fb3dc commit 98c2282
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 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/spinv_ir_block_test.go
Expand Up @@ -19,6 +19,8 @@ import (

var spinVditorIRBlockDOMTests = []*parseTest{

{"2", "<p data-block=\"0\" data-node-id=\"20200915173154-1wi2p2h\" data-type=\"p\">$$<wbr></p>", "<div data-block=\"0\" data-node-id=\"20200915173154-1wi2p2h\" data-type=\"math-block\" class=\"vditor-ir__node vditor-ir__node--expand\"><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\"><wbr>\n</code></pre><pre class=\"vditor-ir__preview\" data-render=\"2\"><code data-type=\"math-block\" class=\"language-math\"></code></pre><span data-type=\"math-block-close-marker\">$$</span></div>"},
{"1", "<p data-block=\"0\" data-node-id=\"20200915172226-iexs3bo\" data-type=\"p\">```<wbr></p>", "<div data-block=\"0\" data-node-id=\"20200915172226-iexs3bo\" data-type=\"code-block\" class=\"vditor-ir__node vditor-ir__node--expand\"><span data-type=\"code-block-open-marker\">```</span><span class=\"vditor-ir__marker vditor-ir__marker--info\" data-type=\"code-block-info\">\u200b<wbr></span><pre class=\"vditor-ir__marker--pre vditor-ir__marker\"><code>\n</code></pre><pre class=\"vditor-ir__preview\" data-render=\"2\"><code></code></pre><span data-type=\"code-block-close-marker\">```</span></div>"},
{"0", "<p data-block=\"0\" data-node-id=\"20200914181352-laa3jyd\" data-type=\"p\">foo<wbr></p>", "<p data-block=\"0\" data-node-id=\"20200914181352-laa3jyd\" data-type=\"p\">foo<wbr></p>"},
}

Expand Down
7 changes: 7 additions & 0 deletions vditor_ir_block.go
Expand Up @@ -33,6 +33,13 @@ func (lute *Lute) SpinVditorIRBlockDOM(ivHTML string) (ovHTML string) {
ivHTML = strings.ReplaceAll(ivHTML, "<wbr>", util.Caret)

markdown := lute.vditorIRBlockDOM2Md(ivHTML)
// 修正 ``` 未闭合时 IAL 错位情况
if strings.HasPrefix(markdown, "```" + util.Caret + "\n{: id=\"") &&
strings.HasSuffix(markdown, "\"}\n") {
lines := strings.Split(markdown, "\n")
markdown = lines[0] + "\n" + strings.ReplaceAll(lines[0], util.Caret, "") + "\n" + lines[1]
}

tree := parse.Parse("", []byte(markdown), lute.Options)
ovHTML = lute.Tree2VditorIRBlockDOM(tree)
// 替换插入符
Expand Down

0 comments on commit 98c2282

Please sign in to comment.