Markdown to docx, including complex template

后端 未结 4 974
温柔的废话
温柔的废话 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 17:51

    Update

    Use the piped version suggested by user Christian Long:

    pandoc -t latex mydoc.md | pandoc -f latex --data-dir=docs/rendering/ -o mydoc.docx
    

    I know this is late in coming, but I'll be assuming people are still searching for solutions to this three years after the original question -- I know I was.

    My solution was to use LaTeX as an intermediary between markdown and docx (actually, I was converting from org-mode, but same difference). So in your case, I believe a one-liner solution would be:

    pandoc -f markdown -t latex -o mydoc.tex mydoc.md && \
    pandoc -f latex -t docx --data-dir=docs/rendering/ -o mydoc.docx mydoc.tex
    

    Which might get you closer to your goal. Of course, Pandoc has about hundred arguments it can handle, and there are probably ways to make this prettier. It has also gotten quite a few updates since you first posted your question.

提交回复
热议问题