What can I control with the YAML header parameters in pandoc?

It was only by chance that I saw an example document using the toc: true in my options for the YAML header in the Markdown file, which will be processed by Pandoc. And Pandoc docs did not mention this option to manage the table of contents using the YAML header. In addition, I see several arbitrary lines in sample documents on the same Pandoc readme site.

The main question:

  • What Pandoc options are available with the YAML header?

meta question:

  • What determines the available Pandoc options that can be set using the YAML header?

Note: my workflow is to use Markdown files ( .md ) and process them through Pandoc to receive the PDF files. It has a hierarchically organized handwritten letter with math. For example:

 pandoc --standalone --smart \ --from=markdown+yaml_metadata_block \ --filter pandoc-citeproc \ my_markdown_file.md \ -o my_pdf_file.pdf 
+36
yaml pandoc
source share
3 answers

Almost everything that is set in the YAML metadata affects only through the template used .

Pandoc templates can contain variables. For example, in your HTML template you can write:

 <title>$title$</title> 

These template variables can be set using the --variable KEY[=VAL] option.

However, they are also set from document metadata, which, in turn, can be set using:

The --variable literally insert lines into the template, and --metadata escapes the lines. Lines in YAML metadata (also when using --metadata-file ) are interpreted as markdowns that can be circumvented using markup pandoc universal raw attributes . For example, for HTML output:

 '<script>alert()</script>'{=html} 

See this table for a diagram :

 | | --variable | --metadata | YAML metadata and --metadata-file | |------------------------|-------------------|-------------------|-----------------------------------| | values can beโ€ฆ | strings and bools | strings and bools | also YAML objects and lists | | strings areโ€ฆ | inserted verbatim | escaped | interpreted as markdown | | accessible by filters: | no | yes | yes | 

To answer your question: the template determines which fields in the YAML metadata block have an effect. For example, to view the default latex template, use:

 $ pandoc -D latex 

To see some variables that pandoc sets automatically, see the manual . Finally, other pandoc behaviors (such as markdown extensions, etc.) can only be specified as command line parameters (except when using a shell script ).

+24
source share

This is a fairly long list, which you can see by running man pandoc on the command line and going to the "Variables defined by pandoc" section in the "TEMPLATES" section.

The following options are listed at the top of the list:

 Variables set by pandoc Some variables are set automatically by pandoc. These vary somewhat depending on the output format, but include metadata fields as well as the following: title, author, date allow identification of basic aspects of the document. Included in PDF metadata through LaTeX and ConTeXt. These can be set through a pandoc title block, which allows for multiple authors, or through a YAML metadata block: --- author: - Aristotle - Peter Abelard ... subtitle document subtitle; also used as subject in PDF metadata abstract document summary, included in LaTeX, ConTeXt, AsciiDoc, and Word docx keywords list of keywords to be included in HTML, PDF, and AsciiDoc metadata; may be repeated as for author, above header-includes contents specified by -H/--include-in-header (may have multiple values) toc non-null value if --toc/--table-of-contents was specified toc-title title of table of contents (works only with EPUB and docx) include-before contents specified by -B/--include-before-body (may have multiple values) include-after contents specified by -A/--include-after-body (may have multiple values) body body of document 

`` ``

+14
source share

You can see the pandoc documentation for a hint: http://pandoc.org/getting-started.html

But to know exactly where it will be used, you can search for pandoc source templates: https://github.com/jgm/pandoc-templates

For example, to output html5 file: https://github.com/jgm/pandoc-templates/blob/master/default.html5

Here's the code section:

 <title>$if(title-prefix)$$title-prefix$ - $endif$$pagetitle$</title> 

As you can see, it has title-prefix and pagetitle .

You can look at the documentation, but the best solution is to search for the source code of the version used.

+3
source share

All Articles