pandoc - 文档格式转换工具中的王者 Oct 06, 2015
[在线编辑]pandoc
pandoc 真可谓是,文档格式转换中的瑞士军刀,支持 markdown, reStructuredText, textile, HTML, DocBook, LaTeX, MediaWiki markup, TWiki markup, OPML, Emacs Org-Mode, Txt2Tags, Microsoft Word docx, EPUB 等等格式。详细的格式转换关系,请看下文中的大图。这又是命令行工具党的 好兵器,不容错过。
我主要,使用 pandoc 转换 HTML、reStructuredText 和 markdown,体验非常好。推荐大家使用。
安装 (Mac OSX)
详细的安装说明,请参考官方文档,我这里只针对 Mac OS X 平台。
$ sudo brew install pandoc
牛刀小试
- 生成 html 文档 (默认无 header 和 footer)
$ pandoc -o output.html input.txt
- 生成标准的 html 文档 (指定 -s 或 –standalone 标识)
$ pandoc -s -o output.html input.txt
- 从 URI 生成转换文档 (html 转 markdown)
$ pandoc -f html -t markdown http://www.fsf.org
- 从 markdown 转 latex 文档
$ pandoc -f markdown -t latex hello.txt
- 从 html 转 markdown 文档 (遵从严格的 markdown 语法)
$ pandoc -f html -t markdown_strict hello.html
- 从 latex 转 pdf 文档
$ pandoc test.txt -o test.pdf
如果想了解更加详细的内容,请参考Pandoc User’s Guide文档。