mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 06:18:49 +01:00
🎨 Improve markdown importing https://github.com/siyuan-note/siyuan/issues/13080
This commit is contained in:
parent
4b0228a297
commit
c5dc86bf8e
1 changed files with 7 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue