Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Add a Ref export mode `Anchor hash` for notebook Markdown exporting https://github.com/siyuan-note/siyuan/issues/10265

Danielf59f738e5edd
diff --git a/kernel/model/export.go b/kernel/model/export.go
index a267533075..d34a64b248 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("<span id=\"" + n.ID + "\"></span>")}
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)
}