[pandoc]文档转换工具

偶然在网上找到一篇文章 - Markdown+Pandoc+Sphinx+ Git 协作写书式推进团队技术文章,里面提到了一个工具pandoc,在网上搜索了其他文章 - 文件格式转换神器-pandoc,发现这是一个通用的文档转换器

Ubuntu安装

下载debpandoc 2.5并安装

sudo dpkg -i pandoc*.deb
sudo apt-get install -f 

测试安装

$ pandoc -v
pandoc 1.19.2.1
Compiled with pandoc-types 1.17.0.4, texmath 0.9, skylighting 0.1.1.4
Default user data directory: /home/zj/.pandoc
Copyright (C) 2006-2016 John MacFarlane
Web:  http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.

格式转换

pandoc支持许多标记语言之间的转换,比如markdownjsonhtmlluareStructuredText等等

目前比较关心的是markdownrst之间的转换,使用如下命令

pandoc test.md -f markdown -t rst -s -o test1.rst
  • test.md是源文件
  • -f表示源文件格式
  • -t表示结果文件格式
  • -s表示生成独立文件
  • -o表示结果文件名

经过测试发现确实有用,能够部分解决sphinxmarkdown数学公式和表格的渲染问题