From f59f738e5eddc591601d79f6ff948650184bf29b Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 28 Jan 2024 10:51:31 +0800 Subject: [PATCH] :art: Add a Ref export mode `Anchor hash` for notebook Markdown exporting https://github.com/siyuan-note/siyuan/issues/10265 --- kernel/model/export.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/model/export.go b/kernel/model/export.go index a26753307..d34a64b24 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -1838,8 +1838,9 @@ func exportMarkdownContent0(tree *parse.Tree, cloudAssetsBase string, assetsDest // 如果是定义块,则在开头处添加锚点 anchorSpan := &ast.Node{Type: ast.NodeInlineHTML, Tokens: []byte("")} if ast.NodeDocument != n.Type { - if nil != n.FirstChild { - n.FirstChild.InsertBefore(anchorSpan) + firstLeaf := treenode.FirstLeafBlock(n) + if nil != firstLeaf && nil != firstLeaf.FirstChild { + firstLeaf.FirstChild.InsertBefore(anchorSpan) } else { n.AppendChild(anchorSpan) }