Pandoc 是一个文档转换器,这个 pandoc 备忘单包含 pandoc 命令和一些常见的 pandoc 技巧
入门
语法
1 | $ pandoc -s [source file] -o [output file] |
安装
安装命令 | 环境 |
---|---|
$ brew install pandoc |
macos |
$ choco install pandoc |
windows |
Debian/Ubuntu
1 | $ sudo apt-get update |
Fedora
1 | $ sudo dnf install pandoc |
Arch Linux
1 | $ sudo pacman -S pandoc |
将 LaTeX 转换为 MS Word
简单的 .tex
到 .docx
1 | $ pandoc -s file.tex -o file.docx |
将 .tex
转换为 .docx
并使用默认引文
1 | $ pandoc -s file.tex --citeproc --bibliography=bib_library.bib -o file.docx |
将 .tex
文件转换为 .docx
文件,并注明具体引文
1 | $ pandoc -s file.tex --citeproc --bibliography=bib_library.bib --csl=apa.csl -o file.docx |
.tex
到 .docx
,带交叉引用
1 | $ pandoc -s file.tex --filter pandoc-crossref -o file.docx |
使用示例
转换文件格式
1 | $ pandoc input.md -o output.pdf |
支持的输入格式
1 | $ pandoc -s input.txt -o output.html |
自定义输出格式
1 | $ pandoc input.md --to=latex -o output.tex |
添加元数据
1 | $ pandoc input.md -o output.pdf --metadata title="My Document" |
从 URL 转换
1 | $ pandoc https://example.com/document.md -o output.pdf |
生成幻灯片
1 | $ pandoc input.md -t beamer -o output.pdf |
合并文件
1 | $ pandoc file1.md file2.md -o output.pdf |
指定样式文件
1 | $ pandoc input.md -o output.pdf --css=style.css |
转换为 AsciiDoc
1 | $ pandoc input.md -o output.asciidoc |
转换为 Docx 格式
1 | $ pandoc input.md -o output.docx |
执行 Lua 过滤器
1 | $ pandoc input.md --lua-filter=custom-filter.lua -o output.pdf |
自动生成目录
1 | $ pandoc input.md -o output.pdf --toc |
禁用目录编号
1 | $ pandoc input.md -o output.pdf --toc --toc-depth=2 |
显示详细信息
1 | $ pandoc input.md -o output.pdf -v |
查看支持的输出格式
1 | $ pandoc --list-output-formats |
评论