🎨 Pandoc template for exporting docx Fix https://github.com/siyuan-note/siyuan/issues/8740

This commit is contained in:
Daniel 2023-09-09 16:38:03 +08:00
parent 982e109af4
commit cc8ee6219c
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
9 changed files with 39 additions and 5 deletions

View file

@ -412,6 +412,19 @@ func ExportDocx(id, savePath string, removeAssets, merge bool) (err error) {
"-o", tmpDocxPath,
}
// Pandoc template for exporting docx https://github.com/siyuan-note/siyuan/issues/8740
docxTemplate := gulu.Str.RemoveInvisible(Conf.Export.DocxTemplate)
docxTemplate = strings.TrimSpace(docxTemplate)
if "" != docxTemplate {
if !gulu.File.IsExist(docxTemplate) {
logging.LogErrorf("docx template [%s] not found", docxTemplate)
msg := fmt.Sprintf(Conf.Language(197), docxTemplate)
return errors.New(msg)
}
args = append(args, "--reference-doc", docxTemplate)
}
pandoc := exec.Command(Conf.Export.PandocBin, args...)
gulu.CmdAttr(pandoc)
pandoc.Stdin = bytes.NewBufferString(content)