指定格式

输入和输出格式可以通过命令行参数来显式指定,输入格式可以通过 -f 或者 —from 参数来指定。输出格式使用 -t 或者 —to 选项来指定,可以通过下面的命令将 hello.txt 将文件从 markdown 转换为 LaTeX 格式。

pandoc -f markdown -t latex hello.txt

下面的命令将 hello.html 从 HTML 转换到 Markdown:

pandoc -f html -t markdown hello.html

Pandoc 支持的格式可以在下面的 Options 章节看到(-f 查看支持的输入格式, -t 查看支持的输出格式),你也可以用使用 —list-input-formats 和 pandoc —list-output-formats 来查看支持的输入和输出格式。

如果不显示指定数输入或者输出格式,pandoc 会尝试根据文件后缀去猜,例如

pandoc -o hello.tex hello.txt

会将 hello.txt 从 Markdown 转化为 LaTeX 格式。如果没有指定输出到文件(会默认输出到标准输出),如果没有指定输出文件的后缀的话会默认为 HTML 格式。如果没有指定输入文件的话默认是标准输入,如果没有指定输入文件格式的话会默认为 Markdown。