Pandoc - 命令行界面的标记语言转换工(瑞士军刀)

AI 摘要: Pandoc是一款跨平台、自由开源的标记语言转换工具

Pandoc是使用Haskell语言编写的一款跨平台、自由开源及命令行界面的标记语言转换工具,可实现不同标记语言间的格式转换,堪称该领域中的“瑞士军刀”

https://pandoc.org/installing.html

安装

1
2
// mac安装
brew install pandoc

快速入门

查看man pandoc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
// md转html,输入完后,按`ctrl+d`
$ pandoc          
Hello *pandoc*!

- one
- two

// html转md,输入完后,按`ctrl+d`
$ pandoc -f html -t markdown
<p>Hello <em>pandoc</em>!</p>

// -f from格式,-t to格式,-s 单独数据, -o output输出文件
$ pandoc -s -f markdown -t html /tmp/pandoc-1.md -o /tmp/pandoc-1.md.html

// 数学公式
echo '$x = y^2$'|pandoc --mathml -o /tmp/pandoc-math.html

编码问题

1
iconv -t utf-8 input.txt | pandoc | iconv -f utf-8

PDF生成

1
pandoc test.txt -o test.pdf

Todo

待发掘…