mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
🎨 Pandoc template for exporting docx Fix https://github.com/siyuan-note/siyuan/issues/8740
This commit is contained in:
parent
982e109af4
commit
cc8ee6219c
9 changed files with 39 additions and 5 deletions
|
|
@ -29,6 +29,7 @@ type Export struct {
|
|||
PandocBin string `json:"pandocBin"` // Pandoc 可执行文件路径
|
||||
MarkdownYFM bool `json:"markdownYFM"` // Markdown 导出时是否添加 YAML Front Matter https://github.com/siyuan-note/siyuan/issues/7727
|
||||
PDFFooter string `json:"pdfFooter"` // PDF 导出时页脚内容
|
||||
DocxTemplate string `json:"docxTemplate"` // Docx 导出时模板文件路径
|
||||
}
|
||||
|
||||
func NewExport() *Export {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue