From 156899cb44a8b863739ddc9256e09471d1ffbd5a Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 9 Oct 2025 20:42:17 +0800 Subject: [PATCH] :art: Improve export of empty documents with subdocuments https://github.com/siyuan-note/siyuan/issues/16040 Signed-off-by: Daniel <845765@qq.com> --- kernel/model/export.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/model/export.go b/kernel/model/export.go index 34ccac57a..b734689a5 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -2039,15 +2039,18 @@ func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []stri return } - for c := tree.Root.FirstChild; nil != c; c = c.Next { - if ast.NodeParagraph == c.Type { - isEmpty = nil == c.FirstChild - if !isEmpty { + refCount := sql.QueryRootChildrenRefCount(tree.ID) + if !Conf.Export.MarkdownYFM && 5 > len(tree.Root.KramdownIAL) && 1 > len(refCount) { + for c := tree.Root.FirstChild; nil != c; c = c.Next { + if ast.NodeParagraph == c.Type { + isEmpty = nil == c.FirstChild + if !isEmpty { + break + } + } else { + isEmpty = false break } - } else { - isEmpty = false - break } }