Skip to content

Commit

Permalink
🐛 Protyle Optimize typography exception in case of task list and he…
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Aug 24, 2023
1 parent ac1fc9a commit d22a9bc
Show file tree
Hide file tree
Showing 4 changed files with 7 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.

5 changes: 4 additions & 1 deletion parse/paragraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ func paragraphFinalize(p *ast.Node, context *Context) (insertTable bool) {
subTree := Parse("", p.Tokens, context.ParseOption)
subBlock := subTree.Root.FirstChild
if ast.NodeParagraph != subBlock.Type {
listItem.PrependChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(" ")})
if !context.ParseOption.ProtyleWYSIWYG {
// Protyle `Optimize typography` exception in case of task list and heading https://github.com/siyuan-note/siyuan/issues/9035
listItem.PrependChild(&ast.Node{Type: ast.NodeText, Tokens: []byte(" ")})
}
if nil != p.FirstChild {
listItem.PrependChild(p.FirstChild)
}
Expand Down
2 changes: 1 addition & 1 deletion test/m2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var md2BlockDOMTests = []parseTest{
{"35", "* {: id=\"20220810110631-x6ycsc2\" updated=\"20220809113836\"}foo\n {: id=\"20220810110631-3ppdll8\" updated=\"20220809113836\"}\n* {: id=\"20220810110631-txapkc7\"}bar\n {: id=\"20220810110631-c5cuvm5\" updated=\"20220809113836\"}\n* {: id=\"20220810110631-fdlccs9\" updated=\"20220809113901\"}\n {: id=\"20220810110631-56rznx9\" updated=\"20220809113836\"}\n{: id=\"20220810110631-jjbmho2\" updated=\"20220809113901\"}\n\nbaz\n{: updated=\"20220809113836\" id=\"20220810110631-bmiq3pg\"}", "<div data-subtype=\"u\" data-node-id=\"20220810110631-jjbmho2\" data-node-index=\"1\" data-type=\"NodeList\" class=\"list\" updated=\"20220809113901\"><div data-marker=\"*\" data-subtype=\"u\" data-node-id=\"20220810110631-x6ycsc2\" data-type=\"NodeListItem\" class=\"li\" updated=\"20220809113836\"><div class=\"protyle-action\" draggable=\"true\"><svg><use xlink:href=\"#iconDot\"></use></svg></div><div data-node-id=\"20220810110631-3ppdll8\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220809113836\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-marker=\"*\" data-subtype=\"u\" data-node-id=\"20220810110631-txapkc7\" data-type=\"NodeListItem\" class=\"li\" updated=\"20220810110631\"><div class=\"protyle-action\" draggable=\"true\"><svg><use xlink:href=\"#iconDot\"></use></svg></div><div data-node-id=\"20220810110631-c5cuvm5\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220809113836\"><div contenteditable=\"true\" spellcheck=\"false\">bar</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-marker=\"*\" data-subtype=\"u\" data-node-id=\"20220810110631-fdlccs9\" data-type=\"NodeListItem\" class=\"li\" updated=\"20220809113901\"><div class=\"protyle-action\" draggable=\"true\"><svg><use xlink:href=\"#iconDot\"></use></svg></div><div data-node-id=\"20220810110631-56rznx9\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220809113836\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20220810110631-bmiq3pg\" data-node-index=\"2\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220809113836\"><div contenteditable=\"true\" spellcheck=\"false\">baz</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"34", "```foo bar\nbaz\n```", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeCodeBlock\" class=\"code-block\" updated=\"20060102150405\"><div class=\"protyle-action\"><span class=\"protyle-action--first protyle-action__language\" contenteditable=\"false\">foo</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\" contenteditable=\"true\" spellcheck=\"false\">baz\n</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"33", "{{{row\n{: id=\"20220426085736-e2v2fzx\"}\n\n{: id=\"20220426085738-q96jknf\"}\n\n{: id=\"20220426085739-6f0aec3\"}\n\n}}}\n{: id=\"20220426085744-ipdufm6\"}\n", "<div data-node-id=\"20220426085744-ipdufm6\" data-node-index=\"1\" data-type=\"NodeSuperBlock\" class=\"sb\" updated=\"20220426085744\" data-sb-layout=\"row\"><div data-node-id=\"20220426085736-e2v2fzx\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220426085736\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20220426085738-q96jknf\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220426085738\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20220426085739-6f0aec3\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20220426085739\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"32", "* [ ] # foo", "<div data-subtype=\"t\" data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeList\" class=\"list\" updated=\"20060102150405\"><div data-marker=\"*\" data-subtype=\"t\" data-node-id=\"20060102150405-1a2b3c4\" data-type=\"NodeListItem\" class=\"li\" updated=\"20060102150405\"> <div class=\"protyle-action protyle-action--task\" draggable=\"true\"><svg><use xlink:href=\"#iconUncheck\"></use></svg></div><div data-subtype=\"h1\" data-node-id=\"20060102150405-1a2b3c4\" data-type=\"NodeHeading\" class=\"h1\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"32", "* [ ] # foo", "<div data-subtype=\"t\" data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeList\" class=\"list\" updated=\"20060102150405\"><div data-marker=\"*\" data-subtype=\"t\" data-node-id=\"20060102150405-1a2b3c4\" data-type=\"NodeListItem\" class=\"li\" updated=\"20060102150405\"><div class=\"protyle-action protyle-action--task\" draggable=\"true\"><svg><use xlink:href=\"#iconUncheck\"></use></svg></div><div data-subtype=\"h1\" data-node-id=\"20060102150405-1a2b3c4\" data-type=\"NodeHeading\" class=\"h1\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"31", "#<a style=\"b\">foo</a>#", "<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\">\u200b&lt;a style=&quot;b&quot;&gt;foo&lt;/a&gt;</span>\u200b</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"30", "<div>foo</div>", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeHTMLBlock\" class=\"render-node\" updated=\"20060102150405\" 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;foo&lt;/div&gt;\"></protyle-html><span style=\"position: absolute\">\u200b</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"29", "{{{\n###### 123\n{: custom-type=\"card\"}\n2022-02-18 23:22:27\n{: custom-type=\"datetime\"}\ncontent\n}}}", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeSuperBlock\" class=\"sb\" updated=\"20060102150405\" data-sb-layout=\"row\"><div data-subtype=\"h6\" data-node-id=\"20060102150405-1a2b3c4\" data-type=\"NodeHeading\" class=\"h6\" custom-type=\"card\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">123</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20060102150405-1a2b3c4\" data-type=\"NodeParagraph\" class=\"p\" custom-type=\"datetime\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">2022-02-18 23:22:27</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div data-node-id=\"20060102150405-1a2b3c4\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">content</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit d22a9bc

Please sign in to comment.