Pandoc 示例
要查看以下每个命令所产生的输出,请点击输出文件的名称。
HTML 片段
pandoc MANUAL.txt -o example1.html
将 MANUAL.txt 文本文件转换为 example1.html (基本的 HTML 片段)。
独立 HTML 文件
pandoc -s MANUAL.txt -o example2.html
带目录、CSS 和自定义页脚的 HTML
pandoc -s --toc -c pandoc.css -A footer.html MANUAL.txt -o example3.html
生成带有目录、外部 CSS 样式表和自定义页脚的 HTML 文件。
LaTeX 转换
pandoc -s MANUAL.txt -o example4.tex
将文本文件转换为 LaTeX 格式。
从 LaTeX 到 Markdown
pandoc -s example4.tex -o example5.text
reStructuredText 转换
pandoc -s -t rst --toc MANUAL.txt -o example6.text
RTF 格式
pandoc -s MANUAL.txt -o example7.rtf
生成富文本格式(RTF)文件。
Beamer 幻灯片
pandoc -t beamer SLIDES -o example8.pdf
DocBook XML
pandoc -s -t docbook MANUAL.txt -o example9.db
Man 页面
pandoc -s -t man pandoc.1.md -o example10.1
ConTeXt 格式
pandoc -s -t context MANUAL.txt -o example11.tex
网页转 Markdown
pandoc -s -r html http://www.gnu.org/software/make/ -o example12.text
从网页直接转换为 Markdown 文本。
Markdown 到 PDF
pandoc MANUAL.txt --pdf-engine=xelatex -o example13.pdf
PDF 增强配置(包含编号章节、自定义 LaTeX 页眉等)
pandoc -N --variable "geometry=margin=1.2in" --variable mainfont="Palatino" --variable sansfont="Helvetica" --variable monofont="Menlo" --variable fontsize=12pt --variable version=2.0 MANUAL.txt --include-in-header fancyheaders.tex --pdf-engine=lualatex --toc -o example14.pdf
Jupyter Notebook
pandoc example15.md -o example15.ipynb
HTML 幻灯片
pandoc -s --mathml -i -t dzslides SLIDES -o example16a.html pandoc -s --webtex -i -t slidy SLIDES -o example16b.html pandoc -s --mathjax -i -t revealjs SLIDES -o example16d.html
数学公式在 HTML 中的渲染
pandoc math.text -s -o mathDefault.html pandoc math.text -s --mathml -o mathMathML.html pandoc math.text -s --webtex -o mathWebTeX.html pandoc math.text -s --mathjax -o mathMathJax.html pandoc math.text -s --katex -o mathKaTeX.html
代码块语法高亮
pandoc code.text -s --highlight-style pygments -o example18a.html pandoc code.text -s --highlight-style kate -o example18b.html pandoc code.text -s --highlight-style monochrome -o example18c.html pandoc code.text -s --highlight-style espresso -o example18d.html pandoc code.text -s --highlight-style haddock -o example18e.html pandoc code.text -s --highlight-style tango -o example18f.html pandoc code.text -s --highlight-style zenburn -o example18g.html
GNU Texinfo:
pandoc MANUAL.txt -s -o example19.texi
OpenDocument XML
pandoc MANUAL.txt -s -t opendocument -o example20.xml
ODT (OpenDocument Text, readable by OpenOffice)
pandoc MANUAL.txt -o example21.odt
MediaWiki markup
pandoc -s -t mediawiki --toc MANUAL.txt -o example22.wiki
EPUB ebook
pandoc MANUAL.txt -o MANUAL.epub
Markdown 引用
pandoc -s --bibliography biblio.bib --citeproc CITATIONS -o example24a.html pandoc -s --bibliography biblio.json --citeproc --csl chicago-fullnote-bibliography.csl CITATIONS -o example24b.html pandoc -s --bibliography biblio.yaml --citeproc --csl ieee.csl CITATIONS -t man -o example24c.1
Textile 编辑器
pandoc -s MANUAL.txt -t textile -o example25.textile
Textile 阅读器
pandoc -s example25.textile -f textile -t html -o example26.html
Org-mode
pandoc -s MANUAL.txt -o example27.org
AsciiDoc
pandoc -s MANUAL.txt -t asciidoc -o example28.txt
转为 docx
pandoc -s MANUAL.txt -o example29.docx
将 LaTeX 数学公式转换为 Docx 文档
pandoc -s math.tex -o example30.docx
DocBook 转为 markdown
pandoc -f docbook -t markdown -s howto.xml -o example31.text
MediaWiki 转为 html5
pandoc -f mediawiki -t html5 -s haskell.wiki -o example32.html
分块 HTML
pandoc -t chunkedhtml --split-level=2 --toc --toc-depth=2 --number-sections -o example33 MANUAL.txt
使用参考模板的 Docx 文档
pandoc --reference-doc twocolumns.docx -o UsersGuide.docx MANUAL.txt
Docx 转为 markdown, 包括数学公式
pandoc -s example30.docx -t markdown -o example35.md
EPUB 转为纯文本
pandoc MANUAL.epub -t plain -o example36.text
使用模板根据结构化数据生成表格
pandoc fishwatch.yaml -t rst --template fishtable.rst -o fish.rst # see also the partial species.rst
将 BibTeX 格式的参考书目转换为 CSL JSON 格式
pandoc biblio.bib -t csljson -o biblio2.json
生成格式化版本的参考文献列表
pandoc biblio.bib --citeproc --csl ieee.csl -s -o biblio.html