Skip to content

Commit 6ee0b66

Browse files
committed
🎨 Supports setting Pandoc parameters for export #16845
Signed-off-by: Daniel <845765@qq.com>
1 parent be79bdd commit 6ee0b66

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

kernel/conf/export.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type Export struct {
3434
FileAnnotationRefMode int `json:"fileAnnotationRefMode"` // 文件标注引用导出模式,0:文件名 - 页码 - 锚文本,1:仅锚文本
3535
PandocBin string `json:"pandocBin"` // Pandoc 可执行文件路径
3636
PandocParams string `json:"pandocParams"` // Pandoc 额外参数
37+
DocxTemplate string `json:"docxTemplate"` // Docx 导出时模板文件路径 TODO 已经废弃,计划于 2026 年 6 月 30 日后删除 https://github.com/siyuan-note/siyuan/issues/16845
3738
RemoveAssetsID bool `json:"removeAssetsID"` // Markdown 导出时是否移除资源文件名 ID 部分 https://github.com/siyuan-note/siyuan/issues/16065
3839
MarkdownYFM bool `json:"markdownYFM"` // Markdown 导出时是否添加 YAML Front Matter https://github.com/siyuan-note/siyuan/issues/7727
3940
InlineMemo bool `json:"inlineMemo"` // 是否导出行级备注 https://github.com/siyuan-note/siyuan/issues/14605

kernel/model/conf.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,17 @@ func InitConf() {
321321
Conf.Export.PandocBin = util.PandocBinPath
322322
}
323323

324+
docxTemplate := util.RemoveInvalid(Conf.Export.DocxTemplate)
325+
if "" != docxTemplate {
326+
params := util.RemoveInvalid(Conf.Export.PandocParams)
327+
if gulu.File.IsExist(docxTemplate) && !strings.Contains(params, "--reference-doc") {
328+
params += " --reference-doc " + docxTemplate
329+
Conf.Export.PandocParams = strings.TrimSpace(params)
330+
}
331+
Conf.Export.DocxTemplate = ""
332+
Conf.Save()
333+
}
334+
324335
if nil == Conf.Graph || nil == Conf.Graph.Local || nil == Conf.Graph.Global {
325336
Conf.Graph = conf.NewGraph()
326337
}

0 commit comments

Comments
 (0)