mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 导出空文档 Word 和 PDF 时合并子文档失败 https://github.com/siyuan-note/siyuan/issues/7429
This commit is contained in:
parent
7c65043b80
commit
8f30e76864
1 changed files with 11 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
)
|
||||
|
||||
func mergeSubDocs(rootTree *parse.Tree) (ret *parse.Tree, err error) {
|
||||
|
|
@ -30,9 +31,6 @@ func mergeSubDocs(rootTree *parse.Tree) (ret *parse.Tree, err error) {
|
|||
}
|
||||
|
||||
insertPoint := rootTree.Root.LastChild
|
||||
if nil == insertPoint {
|
||||
insertPoint = rootTree.Root
|
||||
}
|
||||
|
||||
// 跳过空段落插入点,向上寻找非空段落
|
||||
for ; nil != insertPoint && ast.NodeParagraph == insertPoint.Type; insertPoint = insertPoint.Previous {
|
||||
|
|
@ -41,6 +39,16 @@ func mergeSubDocs(rootTree *parse.Tree) (ret *parse.Tree, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// 如果找不到非空段落,则使用第一个段落作为插入点
|
||||
if nil == insertPoint {
|
||||
insertPoint = rootTree.Root.FirstChild
|
||||
if nil == insertPoint {
|
||||
// 如果文档为空,则创建一个空段落作为插入点
|
||||
insertPoint = treenode.NewParagraph()
|
||||
rootTree.Root.AppendChild(insertPoint)
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
i := 0
|
||||
if err = walkBlock(insertPoint, rootBlock, i); nil != err {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue