🎨 Improve exporting block ref https://github.com/siyuan-note/siyuan/issues/13283
This commit is contained in:
parent
2292f1a0a5
commit
39ddd18616
1 changed files with 10 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue