Skip to content

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

:art: Improve block ref exporting https://github.com/siyuan-note/siyuan/issues/14710

Danielb210a4788df3
diff --git a/kernel/model/export.go b/kernel/model/export.go
index e7459201c8..0b9688cf08 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -2331,7 +2331,31 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
}
} else {
if 4 == blockRefMode { // 脚注+锚点哈希
- if addDocAnchorSpan {
+ refRoot := false
+
+ for _, refFoot := range refFootnotes {
+ if id == refFoot.defID {
+ refRoot = true
+ break
+ }
+ }
+
+ footnotesDefs := tree.Root.ChildrenByType(ast.NodeFootnotesDef)
+ for _, footnotesDef := range footnotesDefs {
+ ast.Walk(footnotesDef, func(n *ast.Node, entering bool) ast.WalkStatus {
+ if !entering {
+ return ast.WalkContinue
+ }
+
+ if id == n.TextMarkBlockRefID {
+ refRoot = true
+ return ast.WalkStop
+ }
+ return ast.WalkContinue
+ })
+ }
+
+ if refRoot && addDocAnchorSpan {
anchorSpan := treenode.NewSpanAnchor(id)
ret.Root.PrependChild(anchorSpan)
}