mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 改进导入 Markdown 文件时解析 HTML 块 Fix https://github.com/siyuan-note/siyuan/issues/7137
This commit is contained in:
parent
83128d2fd8
commit
fd2f3c4328
1 changed files with 17 additions and 0 deletions
|
|
@ -467,6 +467,23 @@ func genTreeID(tree *parse.Tree) {
|
||||||
n.ID = n.IALAttr("id")
|
n.ID = n.IALAttr("id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ast.NodeHTMLBlock == n.Type {
|
||||||
|
tokens := bytes.TrimSpace(n.Tokens)
|
||||||
|
if !bytes.HasPrefix(tokens, []byte("<div>")) {
|
||||||
|
tokens = []byte("<div>\n" + string(tokens))
|
||||||
|
}
|
||||||
|
if !bytes.HasSuffix(tokens, []byte("</div>")) {
|
||||||
|
tokens = append(tokens, []byte("\n</div>")...)
|
||||||
|
}
|
||||||
|
n.Tokens = tokens
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
if ast.NodeInlineHTML == n.Type {
|
||||||
|
n.Type = ast.NodeText
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
if ast.NodeParagraph == n.Type && nil != n.FirstChild && ast.NodeTaskListItemMarker == n.FirstChild.Type {
|
if ast.NodeParagraph == n.Type && nil != n.FirstChild && ast.NodeTaskListItemMarker == n.FirstChild.Type {
|
||||||
// 踢掉任务列表的第一个子节点左侧空格
|
// 踢掉任务列表的第一个子节点左侧空格
|
||||||
n.FirstChild.Next.Tokens = bytes.TrimLeft(n.FirstChild.Next.Tokens, " ")
|
n.FirstChild.Next.Tokens = bytes.TrimLeft(n.FirstChild.Next.Tokens, " ")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue