Skip to content

Commit

Permalink
🐛 Protyle HTML block parsing siyuan-note/siyuan#11623
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jun 3, 2024
1 parent e36a63b commit fcdd3f3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 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: 2 additions & 1 deletion parse/html_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ func HtmlBlockStart(t *Tree, container *ast.Node) int {
if t.Context.ParseOption.ProtyleWYSIWYG {
// Protyle WYSIWYG 模式下,只有 <div 开头的块级元素才能被解析为 HTML 块
// Only HTML code wrapped in `<div>` is supported to be parsed into HTML blocks https://github.com/siyuan-note/siyuan/issues/9758
if !bytes.HasPrefix(t.Context.currentLine, []byte("<div")) {
_, start := lex.TrimLeft(t.Context.currentLine)
if !bytes.HasPrefix(start, []byte("<div")) {
return 0
}
}
Expand Down
1 change: 1 addition & 0 deletions test/m2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var md2BlockDOMTests = []parseTest{

{"83", "* {: id=\"20240603114014-or9nbyv\" updated=\"20240603114628\"}\n <div>\n foo\n </div>\n {: id=\"20240603114015-u94uyd8\" updated=\"20240603114628\"}\n{: id=\"20240603094127-gzqoee7\" updated=\"20240603114628\"}\n\n{: id=\"20240603114213-a343v4t\" updated=\"20240603114213\"}\n", "<div data-subtype=\"u\" data-node-id=\"20240603094127-gzqoee7\" data-node-index=\"1\" data-type=\"NodeList\" class=\"list\" updated=\"20240603114628\"><div data-marker=\"*\" data-subtype=\"u\" data-node-id=\"20240603114014-or9nbyv\" data-type=\"NodeListItem\" class=\"li\" updated=\"20240603114628\"><div class=\"protyle-action\" draggable=\"true\"><svg><use xlink:href=\"#iconDot\"></use></svg></div><div data-node-id=\"20060102150405-1a2b3c4\" 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;\nfoo\n&lt;/div&gt;\n{: id=&quot;20240603114015-u94uyd8&quot; updated=&quot;20240603114628&quot;}\"></protyle-html><span style=\"position: absolute\">\u200b</span></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=\"20240603114213-a343v4t\" data-node-index=\"2\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20240603114213\"><div contenteditable=\"true\" spellcheck=\"false\"></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"82", "|参数|作用|\n| -----------------------| ------------------------------|\n|listen\\=[YES&#124;NO]|是否以独立运行的方式监听服务|", "<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 /><col /></colgroup><thead><tr><th>参数</th><th>作用</th></tr></thead><tbody><tr><td>listen<span data-type=\"backslash\">=</span>[YES&#124;NO]</td><td>是否以独立运行的方式监听服务</td></tr></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>"},
{"81", "[在必应搜索 \"你好\"](www.bing.com/search?q=\"你好\")", "<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=\"a\" data-href=\"www.bing.com/search?q=&amp;quot;你好&amp;quot;\">在必应搜索 &quot;你好&quot;</span></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"80", "foo<u>bar</u>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=\"u\">bar</span>baz</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit fcdd3f3

Please sign in to comment.