Skip to content

Commit

Permalink
🎨 Improve exporting block ref #13283
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Nov 28, 2024
1 parent 7884b62 commit e1a9051
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions kernel/model/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2148,32 +2148,27 @@ func exportTree(tree *parse.Tree, wysiwyg, keepFold, avHiddenCol bool,

if 4 == blockRefMode { // 块引转脚注
unlinks = nil
if footnotesDefBlock := resolveFootnotesDefs(&refFootnotes, ret, currentTreeNodeIDs, blockRefTextLeft, blockRefTextRight); nil != footnotesDefBlock {
footnotesDefBlock := resolveFootnotesDefs(&refFootnotes, ret, currentTreeNodeIDs, blockRefTextLeft, blockRefTextRight)
if nil != footnotesDefBlock {
// 如果是聚焦导出,可能存在没有使用的脚注定义块,在这里进行清理
// Improve focus export conversion of block refs to footnotes https://github.com/siyuan-note/siyuan/issues/10647
//footnotesRefs := ret.Root.ChildrenByType(ast.NodeFootnotesRef)
//for _, ref := range footnotesRefs {
// ast.Walk(ref, func(n *ast.Node, entering bool) ast.WalkStatus {
// if !entering {
// return ast.WalkContinue
// }
//
// if treenode.IsBlockRef(n) {
// refIDsInfnDefs[n.TextMarkBlockRefID] = true
// }
// return ast.WalkContinue
// })
//}
//
//for footnotesDef := footnotesDefBlock.FirstChild; nil != footnotesDef; footnotesDef = footnotesDef.Next {
// exist := refIDsInfnDefs[footnotesDef.ID]
// if !exist {
// unlinks = append(unlinks, footnotesDef)
// }
//}
//for _, n := range unlinks {
// n.Unlink()
//}
footnotesRefs := ret.Root.ChildrenByType(ast.NodeFootnotesRef)
for footnotesDef := footnotesDefBlock.FirstChild; nil != footnotesDef; footnotesDef = footnotesDef.Next {
exist := false
for _, ref := range footnotesRefs {
if ref.FootnotesRefId == footnotesDef.FootnotesRefId {
exist = true
break
}
}
if !exist {
unlinks = append(unlinks, footnotesDef)
}
}

for _, n := range unlinks {
n.Unlink()
}

ret.Root.AppendChild(footnotesDefBlock)
}
Expand Down

0 comments on commit e1a9051

Please sign in to comment.