Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set default options for pandoc?

Tags:

pandoc

Is it at all possible to set default options for pandoc? For example, I always want to use xelatex to generate PDFs, and as far as I can tell, my options for doing so are to pass --latex-engine=xelatex to every invocation of pandoc, or to write a wrapper script that just calls pandoc with that option.

Both of these seem suboptimal to me, and nearly every other command-line program has ways to get around this. Sometimes it's done with an environment variable in the shell (something like setting PANDOC_OPTS="--latex-engine=xelatex"), and other times it's a configuration file (ala ~/.gitconfig or the like). I know pandoc has a data directory at ~/.pandoc, but from my reading of the documentation there is no way to do this.

like image 221
Michael M. Avatar asked Oct 18 '16 15:10

Michael M.


Video Answer


1 Answers

Since pandoc 2.8, one can provide default options via the --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.

like image 186
tarleb Avatar answered Jan 03 '23 13:01

tarleb