mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-27 02:36:10 +01:00
🎨 New export settings: Include sub-docs, Include related docs https://github.com/siyuan-note/siyuan/issues/13635
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
b2f8807dc0
commit
cf79a5db32
20 changed files with 112 additions and 8 deletions
|
|
@ -38,6 +38,8 @@ type Export struct {
|
|||
RemoveAssetsID bool `json:"removeAssetsID"` // Markdown 导出时是否移除资源文件名 ID 部分 https://github.com/siyuan-note/siyuan/issues/16065
|
||||
MarkdownYFM bool `json:"markdownYFM"` // Markdown 导出时是否添加 YAML Front Matter https://github.com/siyuan-note/siyuan/issues/7727
|
||||
InlineMemo bool `json:"inlineMemo"` // 是否导出行级备注 https://github.com/siyuan-note/siyuan/issues/14605
|
||||
IncludeSubDocs bool `json:"includeSubDocs"` // 是否导出子文档 https://github.com/siyuan-note/siyuan/issues/13635
|
||||
IncludeRelatedDocs bool `json:"includeRelatedDocs"` // 是否导出关联文档 https://github.com/siyuan-note/siyuan/issues/13635
|
||||
PDFFooter string `json:"pdfFooter"` // PDF 导出时页脚内容
|
||||
PDFWatermarkStr string `json:"pdfWatermarkStr"` // PDF 导出时水印文本或水印文件路径
|
||||
PDFWatermarkDesc string `json:"pdfWatermarkDesc"` // PDF 导出时水印位置、大小和样式等
|
||||
|
|
|
|||
|
|
@ -514,9 +514,12 @@ func ExportSYs(ids []string) (zipPath string) {
|
|||
bts := treenode.GetBlockTrees(ids)
|
||||
for _, bt := range bts {
|
||||
docPaths = append(docPaths, bt.Path)
|
||||
docFiles := box.ListFiles(strings.TrimSuffix(bt.Path, ".sy"))
|
||||
for _, docFile := range docFiles {
|
||||
docPaths = append(docPaths, docFile.path)
|
||||
|
||||
if Conf.Export.IncludeSubDocs {
|
||||
docFiles := box.ListFiles(strings.TrimSuffix(bt.Path, ".sy"))
|
||||
for _, docFile := range docFiles {
|
||||
docPaths = append(docPaths, docFile.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
zipPath = exportSYZip(block.BoxID, path.Dir(block.Path), baseFolderName, docPaths)
|
||||
|
|
@ -1705,9 +1708,12 @@ func ExportPandocConvertZip(ids []string, pandocTo, ext string) (name, zipPath s
|
|||
bts := treenode.GetBlockTrees(ids)
|
||||
for _, bt := range bts {
|
||||
docPaths = append(docPaths, bt.Path)
|
||||
docFiles := box.ListFiles(strings.TrimSuffix(bt.Path, ".sy"))
|
||||
for _, docFile := range docFiles {
|
||||
docPaths = append(docPaths, docFile.path)
|
||||
|
||||
if Conf.Export.IncludeSubDocs {
|
||||
docFiles := box.ListFiles(strings.TrimSuffix(bt.Path, ".sy"))
|
||||
for _, docFile := range docFiles {
|
||||
docPaths = append(docPaths, docFile.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3617,6 +3623,9 @@ func exportRefTrees(tree *parse.Tree, defBlockIDs *[]string, retTrees, treeCache
|
|||
}
|
||||
*defBlockIDs = append(*defBlockIDs, defID)
|
||||
|
||||
if !Conf.Export.IncludeRelatedDocs {
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
exportRefTrees(defTree, defBlockIDs, retTrees, treeCache)
|
||||
} else if treenode.IsBlockLink(n) {
|
||||
defID := strings.TrimPrefix(n.TextMarkAHref, "siyuan://blocks/")
|
||||
|
|
@ -3641,6 +3650,9 @@ func exportRefTrees(tree *parse.Tree, defBlockIDs *[]string, retTrees, treeCache
|
|||
}
|
||||
*defBlockIDs = append(*defBlockIDs, defID)
|
||||
|
||||
if !Conf.Export.IncludeRelatedDocs {
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
exportRefTrees(defTree, defBlockIDs, retTrees, treeCache)
|
||||
} else if ast.NodeAttributeView == n.Type {
|
||||
// 导出数据库所在文档时一并导出绑定块所在文档
|
||||
|
|
@ -3684,6 +3696,9 @@ func exportRefTrees(tree *parse.Tree, defBlockIDs *[]string, retTrees, treeCache
|
|||
}
|
||||
*defBlockIDs = append(*defBlockIDs, val.BlockID)
|
||||
|
||||
if !Conf.Export.IncludeRelatedDocs {
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
exportRefTrees(defTree, defBlockIDs, retTrees, treeCache)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue