Markdown to docx, including complex template

后端 未结 4 972
温柔的废话
温柔的废话 2020-12-22 17:01

I have automated my build to convert Markdown files to DOCX files using Pandoc. I have even used a reference document for the final document\'s styling. The command I use is

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-22 18:00

    Ideally you could use a custom docx template, but pandoc doesn't support that yet. A reference.docx file only allows custom styles to be embedded in newly created docx files.

    Fortunately you can approximate this using odt instead of docx. You can fairly easily modify the default OpenDocument template to include your custom logos, preamble, and other stuff. Use the custom template in conjunction with a reference.odt file to get all the styles and custom content.

    Once you have the file in odt format, you can use any number of command line tools to convert from odt to docx. For example, on Linux you can run

    libreoffice --invisible --convert-to docx test.odt
    

    Or on OS X:

    /Applications/LibreOffice.app/Contents/MacOS/soffice.bin --invisible --convert-to docx test.odt
    

提交回复
热议问题