This commit is contained in:
Daniel 2024-11-08 11:44:57 +08:00
parent 4b0228a297
commit c5dc86bf8e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -1102,7 +1102,7 @@ func imgHtmlBlock2InlineImg(tree *parse.Tree) {
return ast.WalkContinue
}
if ast.NodeHTMLBlock == n.Type {
if ast.NodeHTMLBlock == n.Type || (ast.NodeText == n.Type && bytes.HasPrefix(bytes.ToLower(n.Tokens), []byte("<img "))) {
tokens := bytes.TrimSpace(n.Tokens)
if bytes.HasPrefix(tokens, []byte("<div>")) {
tokens = bytes.TrimPrefix(tokens, []byte("<div>"))
@ -1151,7 +1151,12 @@ func imgHtmlBlock2InlineImg(tree *parse.Tree) {
}
img.AppendChild(&ast.Node{Type: ast.NodeCloseParen})
n.InsertBefore(p)
if nil != n.Parent && ast.NodeText == n.Type {
// 行级 HTML 会被解析为文本,所以这里要在父级段落前面插入,避免形成段落嵌套 https://github.com/siyuan-note/siyuan/issues/13080
n.Parent.InsertBefore(p)
} else {
n.InsertBefore(p)
}
n.Unlink()
}
return