🎨 Improve export of empty documents with subdocuments https://github.com/siyuan-note/siyuan/issues/16040

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-10-09 22:48:22 +08:00
parent 156899cb44
commit 4c0d3365f1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 5 additions and 1 deletions

View file

@ -2040,7 +2040,7 @@ func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []stri
}
refCount := sql.QueryRootChildrenRefCount(tree.ID)
if !Conf.Export.MarkdownYFM && 5 > len(tree.Root.KramdownIAL) && 1 > len(refCount) {
if !Conf.Export.MarkdownYFM && treenode.ContainOnlyDefaultIAL(tree) && 1 > len(refCount) {
for c := tree.Root.FirstChild; nil != c; c = c.Next {
if ast.NodeParagraph == c.Type {
isEmpty = nil == c.FirstChild

View file

@ -125,3 +125,7 @@ func NewParagraph(id string) (ret *ast.Node) {
func NewSpanAnchor(id string) (ret *ast.Node) {
return &ast.Node{Type: ast.NodeInlineHTML, Tokens: []byte("<span id=\"" + id + "\" style=\"display: none;\"></span>")}
}
func ContainOnlyDefaultIAL(tree *parse.Tree) bool {
return 5 > len(tree.Root.KramdownIAL)
}