Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Supports setting Pandoc parameters for export https://github.com/siyuan-note/siyuan/issues/16845

Daniel6ee0b663e2c5
diff --git a/kernel/conf/export.go b/kernel/conf/export.go
index 506b401650..962fd3d5b8 100644
--- a/kernel/conf/export.go
+++ b/kernel/conf/export.go
@@ -34,6 +34,7 @@ type Export struct {
FileAnnotationRefMode int `json:"fileAnnotationRefMode"` // 文件标注引用导出模式,0:文件名 - 页码 - 锚文本,1:仅锚文本
PandocBin string `json:"pandocBin"` // Pandoc 可执行文件路径
PandocParams string `json:"pandocParams"` // Pandoc 额外参数
+ DocxTemplate string `json:"docxTemplate"` // Docx 导出时模板文件路径 TODO 已经废弃,计划于 2026 年 6 月 30 日后删除 https://github.com/siyuan-note/siyuan/issues/16845
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
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index c617b5385f..571abcb5df 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -321,6 +321,17 @@ func InitConf() {
Conf.Export.PandocBin = util.PandocBinPath
}
+ docxTemplate := util.RemoveInvalid(Conf.Export.DocxTemplate)
+ if "" != docxTemplate {
+ params := util.RemoveInvalid(Conf.Export.PandocParams)
+ if gulu.File.IsExist(docxTemplate) && !strings.Contains(params, "--reference-doc") {
+ params += " --reference-doc " + docxTemplate
+ Conf.Export.PandocParams = strings.TrimSpace(params)
+ }
+ Conf.Export.DocxTemplate = ""
+ Conf.Save()
+ }
+
if nil == Conf.Graph || nil == Conf.Graph.Local || nil == Conf.Graph.Global {
Conf.Graph = conf.NewGraph()
}