Skip to content

Commit

Permalink
🎨 Improve focus export PDF conversion of block refs to footnotes siyu…
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Mar 19, 2024
1 parent 83fbf8c commit 0fd9947
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions kernel/model/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,8 @@ func prepareExportTree(bt *treenode.BlockTree) (ret *parse.Tree) {
oldRoot := ret.Root
ret = parse.Parse("", []byte(""), luteEngine.ParseOptions)
first := ret.Root.FirstChild
for _, node := range nodes {
first.InsertBefore(node)
for _, n := range nodes {
first.InsertBefore(n)
}
ret.Root.KramdownIAL = oldRoot.KramdownIAL
}
Expand Down Expand Up @@ -2107,7 +2107,27 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
}

if 4 == blockRefMode { // 块引转脚注
unlinks = nil
if footnotesDefBlock := resolveFootnotesDefs(&refFootnotes, ret.Root.ID, blockRefTextLeft, blockRefTextRight); nil != footnotesDefBlock {
// 如果是聚焦导出,可能存在没有使用的脚注定义块,在这里进行清理
// Improve focus export PDF conversion of block refs to footnotes https://github.com/siyuan-note/siyuan/issues/10647
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 0fd9947

Please sign in to comment.