Skip to content

Commit

Permalink
🎨 Protyle Improve span parsing siyuan-note/siyuan#13420
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 11, 2024
1 parent 8900076 commit 29c4244
Show file tree
Hide file tree
Showing 4 changed files with 6 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/inline_html.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ func (t *Tree) processSpanTag(tags []byte, startTag, endTag string, ctx *InlineC
}

end := bytes.Index(remains, []byte(endTag))
if -1 == end {
innerStartTagIndex := bytes.Index(remains, []byte(startTag))
if (bytes.Contains(remains, []byte(startTag)) && -1 < end && innerStartTagIndex < end) || -1 == end {
ret = &ast.Node{Type: ast.NodeInlineHTML, Tokens: tags}
return
}
Expand Down
2 changes: 2 additions & 0 deletions test/spin_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

var spinBlockDOMTests = []*parseTest{

{"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>"},
{"236", "<div data-node-id=\"20241201123502-sm8drny\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241201173738\"><div contenteditable=\"true\" spellcheck=\"false\">​<span contenteditable=\"false\" data-type=\"img\" class=\"img\" style=\"min-width: calc(100% - 0.1em);\"><span> </span><span style=\" width: 469px;\"><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-20241201123502-bou3n94.png\" data-src=\"assets/image-20241201123502-bou3n94.png\" loading=\"lazy\" alt=\"image\" style=\"height: 67vh;\"><span class=\"protyle-action__drag\"></span><span class=\"protyle-action__title\"><span></span></span></span><span> </span></span>1<wbr><br></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241201123502-sm8drny\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241201173738\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span contenteditable=\"false\" data-type=\"img\" class=\"img\" style=\"min-width: calc(100% - 0.1em);\"><span> </span><span style=\"width: 469px;\"><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-20241201123502-bou3n94.png\" data-src=\"assets/image-20241201123502-bou3n94.png\" loading=\"lazy\" alt=\"image\" style=\"height: 67vh;\" /><span class=\"protyle-action__drag\"></span><span class=\"protyle-action__title\"><span></span></span></span><span> </span></span>1<wbr><br /></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"235", "<div data-node-id=\"20241128232043-eoqqryw\" data-node-index=\"0\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241128232125\"><div contenteditable=\"true\" spellcheck=\"true\">​<span contenteditable=\"false\" data-type=\"img\" class=\"img\" style=\"min-width: calc(100% - 0.1em);\"><span> </span><span style=\"width: 326px;\"><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-20241128165830-k4724tn.png\" data-src=\"assets/image-20241128165830-k4724tn.png\" loading=\"lazy\" alt=\"提示文本\" title=\"标题\"><span class=\"protyle-action__drag\"></span><span class=\"protyle-action__title\"><span>标题</span></span></span><span> </span></span>1<wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241128232043-eoqqryw\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241128232125\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span contenteditable=\"false\" data-type=\"img\" class=\"img\" style=\"min-width: calc(100% - 0.1em);\"><span> </span><span style=\"width: 326px;\"><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-20241128165830-k4724tn.png\" data-src=\"assets/image-20241128165830-k4724tn.png\" loading=\"lazy\" alt=\"提示文本\" title=\"标题\" /><span class=\"protyle-action__drag\"></span><span class=\"protyle-action__title\"><span>标题</span></span></span><span> </span></span>1<wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"234", "<div data-node-id=\"20241106095909-yx1lagp\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20241106100003\" style=\"background-color: var(--b3-card-info-background); color: var(--b3-card-info-color);\"><div contenteditable=\"true\" spellcheck=\"false\">foo <span data-type=\"strong\">bar</span> baz <wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">​</div></div>", "<div data-node-id=\"20241106095909-yx1lagp\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" style=\"background-color: var(--b3-card-info-background); color: var(--b3-card-info-color);\" updated=\"20241106100003\"><div contenteditable=\"true\" spellcheck=\"false\">foo <span data-type=\"strong\">bar</span> baz <wbr></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit 29c4244

Please sign in to comment.