Skip to content

Commit

Permalink
🎨 Protyle Improve processing when copying and pasting plain text cont…
Browse files Browse the repository at this point in the history
…ains escape char siyuan-note/siyuan#9727
  • Loading branch information
88250 committed Nov 24, 2023
1 parent 2357639 commit 3ec0c8f
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 139 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: 0 additions & 3 deletions render/protyle_export_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,6 @@ func (r *ProtyleExportRenderer) renderBackslashContent(node *ast.Node, entering
func (r *ProtyleExportRenderer) renderBackslash(node *ast.Node, entering bool) ast.WalkStatus {
if entering {
r.WriteString("<span data-type=\"backslash\">")
r.WriteString("<span>")
r.WriteByte(lex.ItemBackslash)
r.WriteString("</span>")
} else {
r.WriteString("</span>")
}
Expand Down
3 changes: 0 additions & 3 deletions render/protyle_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,6 @@ func (r *ProtyleRenderer) renderBackslashContent(node *ast.Node, entering bool)
func (r *ProtyleRenderer) renderBackslash(node *ast.Node, entering bool) ast.WalkStatus {
if entering {
r.WriteString("<span data-type=\"backslash\">")
r.WriteString("<span>")
r.WriteByte(lex.ItemBackslash)
r.WriteString("</span>")
} else {
r.WriteString("</span>")
}
Expand Down
4 changes: 2 additions & 2 deletions test/m2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

var md2BlockDOMTests = []parseTest{

{"77", "\\*foo\\*", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\"><span data-type=\"backslash\"><span>\\</span>*</span>foo<span data-type=\"backslash\"><span>\\</span>*</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"77", "\\*foo\\*", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\"><span data-type=\"backslash\">*</span>foo<span data-type=\"backslash\">*</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"76", "| `foo\\\\\\|bar` |\n| - |", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeTable\" class=\"table\" updated=\"20060102150405\"><div contenteditable=\"false\"><table contenteditable=\"true\" spellcheck=\"false\"><colgroup><col /></colgroup><thead><tr><th>\u200b<span data-type=\"code\">\u200bfoo\\\\&#124;bar</span>\u200b</th></tr></thead><tbody></tbody></table><div class=\"protyle-action__table\"><div class=\"table__resize\"></div><div class=\"table__select\"></div></div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"75", "| `foo\\\\|bar` |\n| - |", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeTable\" class=\"table\" updated=\"20060102150405\"><div contenteditable=\"false\"><table contenteditable=\"true\" spellcheck=\"false\"><colgroup><col /></colgroup><thead><tr><th>\u200b<span data-type=\"code\">\u200bfoo\\&#124;bar</span>\u200b</th></tr></thead><tbody></tbody></table><div class=\"protyle-action__table\"><div class=\"table__resize\"></div><div class=\"table__select\"></div></div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"74", "| `foo\\|bar` |\n| - |", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeTable\" class=\"table\" updated=\"20060102150405\"><div contenteditable=\"false\"><table contenteditable=\"true\" spellcheck=\"false\"><colgroup><col /></colgroup><thead><tr><th>\u200b<span data-type=\"code\">\u200bfoo&#124;bar</span>\u200b</th></tr></thead><tbody></tbody></table><div class=\"protyle-action__table\"><div class=\"table__resize\"></div><div class=\"table__select\"></div></div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand All @@ -43,7 +43,7 @@ var md2BlockDOMTests = []parseTest{
{"56", "foo&lt;bar&gt;baz", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo&lt;bar&gt;baz</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"55", "foo\n{: style=\"color: green\"}\n\n{: style=\"color: green\"}\n\nbar", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" style=\"color: green\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"2\" data-type=\"NodeParagraph\" class=\"p\" style=\"color: green\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"3\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">bar</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"54", "foo==bar==baz", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo<span data-type=\"mark\">bar</span>baz</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"53", "foo\\\\\\~bar\\\\\\~baz", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo<span data-type=\"backslash\"><span>\\</span>\\</span><span data-type=\"backslash\"><span>\\</span>~</span>bar<span data-type=\"backslash\"><span>\\</span>\\</span><span data-type=\"backslash\"><span>\\</span>~</span>baz</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"53", "foo\\\\\\~bar\\\\\\~baz", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo<span data-type=\"backslash\">\\</span><span data-type=\"backslash\">~</span>bar<span data-type=\"backslash\">\\</span><span data-type=\"backslash\">~</span>baz</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"52", "<div>\n<details>\n<summary>foo</summary>\n</div>\n{: id=\"20221022222200-2b6wj74\" updated=\"20221022222200\"}\n", "<div data-node-id=\"20221022222200-2b6wj74\" data-node-index=\"1\" data-type=\"NodeHTMLBlock\" class=\"render-node\" updated=\"20221022222200\" data-subtype=\"block\"><div class=\"protyle-icons\"><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-icon--first protyle-action__edit\"><svg><use xlink:href=\"#iconEdit\"></use></svg></span><span class=\"b3-tooltips__nw b3-tooltips protyle-icon protyle-action__menu protyle-icon--last\"><svg><use xlink:href=\"#iconMore\"></use></svg></span></div><div><protyle-html data-content=\"&lt;div&gt;\n&lt;details&gt;\n&lt;summary&gt;foo&lt;/summary&gt;\n&lt;/div&gt;\"></protyle-html><span style=\"position: absolute\">\u200b</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"51", "~~~foo~~~", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\"><span data-type=\"sub s\">foo</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"50", "#foo'bar#", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span data-type=\"tag\">\u200bfoo'bar</span>\u200b</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down
Loading

0 comments on commit 3ec0c8f

Please sign in to comment.