🎨 Improve parsing <img> tags when importing https://github.com/siyuan-note/siyuan/issues/15638

This commit is contained in:
Daniel 2025-08-23 11:15:50 +08:00
parent cd7734ba91
commit c521a0f985
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1392,12 +1392,19 @@ func htmlBlock2Inline(tree *parse.Tree) {
img.InsertAfter(ial)
}
if nil != n.Parent && ast.NodeText == n.Type {
// 行级 HTML 会被解析为文本,所以这里要在父级段落前面插入,避免形成段落嵌套 https://github.com/siyuan-note/siyuan/issues/13080
n.Parent.InsertBefore(p)
if ast.NodeHTMLBlock == n.Type {
n.InsertBefore(p)
} else if ast.NodeText == n.Type {
if nil != n.Parent {
if n.Parent.IsContainerBlock() {
n.InsertBefore(p)
} else {
n.InsertBefore(img)
}
} else {
n.InsertBefore(p)
}
}
unlinks = append(unlinks, n)
}