是否可以为 pandoc 设置默认选项?

Is it possible to set default options for pandoc?

是否可以为 pandoc 设置默认选项?例如,我 总是 想使用 xelatex 生成 PDF,据我所知,我的选择是将 --latex-engine=xelatex 传递给 每次 调用 pandoc,或者编写一个只使用该选项调用 pandoc 的包装脚本。

这两个对我来说似乎都不是最佳选择,几乎所有其他命令行程序都有办法解决这个问题。有时它是通过 shell 中的环境变量完成的(类似于设置 PANDOC_OPTS="--latex-engine=xelatex"),而其他时候它是配置文件(ala ~/.gitconfig 等)。我知道 pandoc 在 ~/.pandoc 有一个数据目录,但从我阅读的文档来看,没有办法做到这一点。

从 pandoc 2.8 开始,可以通过 --defaults command line parameter:

提供默认选项

-d FILE, --defaults=FILE

Specify a set of default option settings. FILE is a YAML file whose fields correspond to command-line option settings. All options for document conversion, including input and output files, can be set using a defaults file. The file will be searched for first in the working directory, and then in the defaults subdirectory of the user data directory (see --data-dir). The .yaml extension may be omitted. See the section Default files for more information on the file format. Settings from the defaults file may be overridden or extended by subsequent options on the command line.