This commit is contained in:
Daniel 2024-12-01 20:49:18 +08:00
parent 2292f1a0a5
commit 39ddd18616
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -2174,7 +2174,7 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
if 4 == blockRefMode { // 块引转脚注
unlinks = nil
footnotesDefBlock := resolveFootnotesDefs(&refFootnotes, ret, currentTreeNodeIDs, blockRefTextLeft, blockRefTextRight)
footnotesDefBlock := resolveFootnotesDefs(&refFootnotes, ret, currentTreeNodeIDs, blockRefTextLeft, blockRefTextRight, &treeCache)
if nil != footnotesDefBlock {
// 如果是聚焦导出,可能存在没有使用的脚注定义块,在这里进行清理
// Improve focus export conversion of block refs to footnotes https://github.com/siyuan-note/siyuan/issues/10647
@ -2633,7 +2633,7 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,
return ret
}
func resolveFootnotesDefs(refFootnotes *[]*refAsFootnotes, currentTree *parse.Tree, currentTreeNodeIDs map[string]bool, blockRefTextLeft, blockRefTextRight string) (footnotesDefBlock *ast.Node) {
func resolveFootnotesDefs(refFootnotes *[]*refAsFootnotes, currentTree *parse.Tree, currentTreeNodeIDs map[string]bool, blockRefTextLeft, blockRefTextRight string, treeCache *map[string]*parse.Tree) (footnotesDefBlock *ast.Node) {
if 1 > len(*refFootnotes) {
return nil
}
@ -2641,10 +2641,15 @@ func resolveFootnotesDefs(refFootnotes *[]*refAsFootnotes, currentTree *parse.Tr
footnotesDefBlock = &ast.Node{Type: ast.NodeFootnotesDefBlock}
var rendered []string
for _, foot := range *refFootnotes {
t, err := LoadTreeByBlockID(foot.defID)
if err != nil {
continue
t := (*treeCache)[foot.defID]
if nil == t {
var err error
if t, err = LoadTreeByBlockID(foot.defID); err != nil {
continue
}
(*treeCache)[t.ID] = t
}
defNode := treenode.GetNodeInTree(t, foot.defID)
docID := util.GetTreeID(defNode.Path)
var nodes []*ast.Node