Skip to content

Commit

Permalink
🎨 Protyle Improve code block parsing siyuan-note/siyuan#13502
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 17, 2024
1 parent 8ec5512 commit 996f9fa
Show file tree
Hide file tree
Showing 4 changed files with 4 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.

3 changes: 1 addition & 2 deletions protyle.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,8 @@ func (lute *Lute) genASTByBlockDOM(n *html.Node, tree *parse.Tree) {
buf := bytes.Buffer{}
for i, line := range lines {
if strings.Contains(line, "```") {
line = strings.ReplaceAll(line, editor.Zwj+"```", "```")
line = strings.ReplaceAll(line, "```", editor.Zwj+"```")
} else {
line = strings.ReplaceAll(line, editor.Zwj, "")
}
buf.WriteString(line)
if i < len(lines)-1 {
Expand Down
1 change: 1 addition & 0 deletions test/spin_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var spinBlockDOMTests = []*parseTest{

{"240", "<div data-node-id=\"20241217101900-0lfsuso\" data-node-index=\"1\" data-type=\"NodeCodeBlock\" class=\"code-block\" updated=\"20241217102406\"><div class=\"protyle-action\"><span class=\"protyle-action--first protyle-action__language\" contenteditable=\"false\"></span><span class=\"fn__flex-1\"></span><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--first protyle-action__copy\" aria-label=\"复制\"><svg><use xlink:href=\"#iconCopy\"></use></svg></span><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--last protyle-action__menu\" aria-label=\"更多\"><svg><use xlink:href=\"#iconMore\"></use></svg></span></div><div class=\"hljs\" style=\"display: block;\"><div class=\"fn__none\"></div><div contenteditable=\"true\" style=\"flex: 1 1 0%; white-space: pre; word-break: initial; font-variant-ligatures: none;\" spellcheck=\"false\">👩‍❤️‍💋‍👨<wbr>\n</div></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241217101900-0lfsuso\" data-node-index=\"1\" data-type=\"NodeCodeBlock\" class=\"code-block\" updated=\"20241217102406\"><div class=\"protyle-action\"><span class=\"protyle-action--first protyle-action__language\" contenteditable=\"false\"></span><span class=\"fn__flex-1\"></span><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--first protyle-action__copy\"><svg><use xlink:href=\"#iconCopy\"></use></svg></span><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--last protyle-action__menu\"><svg><use xlink:href=\"#iconMore\"></use></svg></span></div><div class=\"hljs\"><div></div><div contenteditable=\"true\" style=\"flex: 1\" spellcheck=\"false\">👩\u200d❤️\u200d💋\u200d👨<wbr>\n</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"239", "<div data-node-id=\"20241216215356-8csb7bj\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241216215405\"><div contenteditable=\"true\" spellcheck=\"false\">​<span contenteditable=\"false\" data-type=\"img\" class=\"img\"><span> </span><span><span class=\"protyle-action protyle-icons\"><span class=\"protyle-icon protyle-icon--only\"><svg class=\"svg\"><use xlink:href=\"#iconMore\"></use></svg></span></span><img src=\" assets/image-20241216215356-kcrpglk.png\" data-src=\" assets/image-20241216215356-kcrpglk.png\" loading=\"lazy\" alt=\"image\"><span class=\"protyle-action__drag\"></span><span class=\"img__net\"><svg><use xlink:href=\"#iconLanguage\"></use></svg></span><span class=\"protyle-action__title\"><span></span></span></span><span> </span></span>​</div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241216215356-8csb7bj\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241216215405\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span contenteditable=\"false\" data-type=\"img\" class=\"img\"><span> </span><span><span class=\"protyle-action protyle-icons\"><span class=\"protyle-icon protyle-icon--only\"><svg class=\"svg\"><use xlink:href=\"#iconMore\"></use></svg></span></span><img src=\"assets/image-20241216215356-kcrpglk.png\" data-src=\"assets/image-20241216215356-kcrpglk.png\" loading=\"lazy\" alt=\"image\" /><span class=\"protyle-action__drag\"></span><span class=\"protyle-action__title\"><span></span></span></span><span> </span></span>\u200b</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"238", "<div data-node-id=\"20241211073144-72jsrs1\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241211073144\"><div contenteditable=\"true\" spellcheck=\"true\">&lt;span data-type=&quot;text&quot; style=&quot;text-emphasis-style: dot; text-emphasis-position: under;&quot;&gt;着重符号&lt;span&gt; <span data-type=\"block-ref\" data-subtype=\"s\" data-id=\"20241210194444-oqwwntf\">*</span></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241211073144-72jsrs1\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241211073144\"><div contenteditable=\"true\" spellcheck=\"false\">&lt;span data-type=&quot;text&quot; style=&quot;text-emphasis-style: dot; text-emphasis-position: under;&quot;&gt; 着重符号 &lt;span&gt; <span data-type=\"block-ref\" data-subtype=\"s\" data-id=\"20241210194444-oqwwntf\">*</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"237", "<div data-node-id=\"20241211073030-vjzgigb\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241211073030\"><div contenteditable=\"true\" spellcheck=\"true\">&lt;span data-type=&quot;text&quot; style=&quot;text-emphasis-style: dot; text-emphasis-position: under;&quot;&gt;着重符号&lt;span&gt;</div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241211073030-vjzgigb\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241211073030\"><div contenteditable=\"true\" spellcheck=\"false\">&lt;span data-type=&quot;text&quot; style=&quot;text-emphasis-style: dot; text-emphasis-position: under;&quot;&gt; 着重符号 &lt;span&gt;</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit 996f9fa

Please sign in to comment.