Skip to content

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

:art: Improve exporting block hyperlink jumping https://github.com/siyuan-note/siyuan/issues/13837

Daniel713c55ed7a39
diff --git a/kernel/model/export.go b/kernel/model/export.go
index 6bfa335a49..be7f5f2727 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -2068,6 +2068,7 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
luteEngine := NewLute()
ret = tree
id := tree.Root.ID
+ (*treeCache)[tree.ID] = tree
// 解析查询嵌入节点
depth := 0
@@ -2799,7 +2800,7 @@ func blockLink2Ref(currentTree *parse.Tree, id string, treeCache *map[string]*pa
if nil == b {
return
}
- t, err := loadTreeWithCache(b.ID, treeCache)
+ t, err := loadTreeWithCache(b.RootID, treeCache)
if nil != err {
return
}
@@ -2849,7 +2850,7 @@ func collectFootnotesDefs(currentTree *parse.Tree, id string, refFootnotes *[]*r
if nil == b {
return
}
- t, err := loadTreeWithCache(b.ID, treeCache)
+ t, err := loadTreeWithCache(b.RootID, treeCache)
if nil != err {
return
}
@@ -3122,12 +3123,12 @@ func prepareExportTrees(docPaths []string) (defBlockIDs []string, trees *map[str
treeCache := &map[string]*parse.Tree{}
defBlockIDs = []string{}
for i, p := range docPaths {
- id := strings.TrimSuffix(path.Base(p), ".sy")
- if !ast.IsNodeIDPattern(id) {
+ rootID := strings.TrimSuffix(path.Base(p), ".sy")
+ if !ast.IsNodeIDPattern(rootID) {
continue
}
- tree, err := loadTreeWithCache(id, treeCache)
+ tree, err := loadTreeWithCache(rootID, treeCache)
if err != nil {
continue
}