An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve export of empty documents with subdocuments https://github.com/siyuan-note/siyuan/issues/15009
Daniel19082e9d5f1e
diff --git a/kernel/model/export.go b/kernel/model/export.goindex 81466c1356..33e6675898 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -1993,13 +1993,13 @@ func ExportMarkdownContent(id string, refMode, embedMode int, addYfm bool) (hPatreturn}-func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []string, singleFile bool, treeCache *map[string]*parse.Tree) (hPath, exportedMd string) {+func exportMarkdownContent(id, ext string, exportRefMode int, defBlockIDs []string, singleFile bool, treeCache *map[string]*parse.Tree) (tree *parse.Tree, exportedMd string, isEmpty bool) {tree, err := loadTreeWithCache(id, treeCache)if err != nil {logging.LogErrorf("load tree by block id [%s] failed: %s", id, err)return}- hPath = tree.HPath+ isEmpty = nil == tree.Root.FirstChild.FirstChildexportedMd = exportMarkdownContent0(tree, "", false,ext, exportRefMode, Conf.Export.BlockEmbedMode, Conf.Export.FileAnnotationRefMode,Conf.Export.TagOpenMarker, Conf.Export.TagCloseMarker,@@ -3128,7 +3128,11 @@ func exportPandocConvertZip(baseFolderName string, docPaths, defBlockIDs []strinluteEngine := util.NewLute()for i, p := range docPaths {id := util.GetTreeID(p)- hPath, md := exportMarkdownContent(id, ext, exportRefMode, defBlockIDs, false, treeCache)+ tree, md, isEmpty := exportMarkdownContent(id, ext, exportRefMode, defBlockIDs, false, treeCache)+ if nil == tree {+ continue+ }+ hPath := tree.HPathdir, name = path.Split(hPath)dir = util.FilterFilePath(dir) // 导出文档时未移除不支持的文件名符号 https://github.com/siyuan-note/siyuan/issues/4590name = util.FilterFileName(name)@@ -3147,8 +3151,17 @@ func exportPandocConvertZip(baseFolderName string, docPaths, defBlockIDs []strincontinue}+ if isEmpty {+ entries, readErr := os.ReadDir(filepath.Join(util.DataDir, tree.Box, strings.TrimSuffix(tree.Path, ".sy")))+ if nil == readErr && 0 < len(entries) {+ // 如果文档内容为空并且存在子文档则仅导出文件夹+ // Improve export of empty documents with subdocuments https://github.com/siyuan-note/siyuan/issues/15009+ continue+ }+ }+// 解析导出后的标准 Markdown,汇总 assets- tree := parse.Parse("", gulu.Str.ToBytes(md), luteEngine.ParseOptions)+ tree = parse.Parse("", gulu.Str.ToBytes(md), luteEngine.ParseOptions)var assets []stringassets = append(assets, assetsLinkDestsInTree(tree)...)for _, asset := range assets {