git.iko.soy/typeable/pandoc
on rc/2.11.0.4 help sign in
typeable/pandoc/MANUAL.txt
6194 lines 211 kB history raw
1---
2title: Pandoc User's Guide
3author: John MacFarlane
4date: October 20, 2020
5---
7# Synopsis
9`pandoc` [*options*] [*input-file*]...
11# Description
13Pandoc is a [Haskell] library for converting from one markup format to
14another, and a command-line tool that uses this library.
16Pandoc can convert between numerous markup and word processing formats,
17including, but not limited to, various flavors of [Markdown], [HTML],
18[LaTeX] and [Word docx]. For the full lists of input and output formats,
19see the `--from` and `--to` [options below][General options].
20Pandoc can also produce [PDF] output: see [creating a PDF], below.
22Pandoc's enhanced version of Markdown includes syntax for [tables],
23[definition lists], [metadata blocks], [footnotes], [citations], [math],
24and much more. See below under [Pandoc's Markdown].
26Pandoc has a modular design: it consists of a set of readers, which parse
27text in a given format and produce a native representation of the document
28(an _abstract syntax tree_ or AST), and a set of writers, which convert
29this native representation into a target format. Thus, adding an input
30or output format requires only adding a reader or writer. Users can also
31run custom [pandoc filters] to modify the intermediate AST.
33Because pandoc's intermediate representation of a document is less
34expressive than many of the formats it converts between, one should
35not expect perfect conversions between every format and every other.
36Pandoc attempts to preserve the structural elements of a document, but
37not formatting details such as margin size. And some document elements,
38such as complex tables, may not fit into pandoc's simple document
39model. While conversions from pandoc's Markdown to all formats aspire
40to be perfect, conversions from formats more expressive than pandoc's
41Markdown can be expected to be lossy.
43## Using pandoc
45If no *input-files* are specified, input is read from *stdin*.
46Output goes to *stdout* by default. For output to a file,
47use the `-o` option:
49 pandoc -o output.html input.txt
51By default, pandoc produces a document fragment. To produce a standalone
52document (e.g. a valid HTML file including `<head>` and `<body>`),
53use the `-s` or `--standalone` flag:
55 pandoc -s -o output.html input.txt
57For more information on how standalone documents are produced, see
58[Templates] below.
60If multiple input files are given, `pandoc` will concatenate them all (with
61blank lines between them) before parsing. (Use `--file-scope` to parse files
62individually.)
64## Specifying formats
66The format of the input and output can be specified explicitly using
67command-line options. The input format can be specified using the
68`-f/--from` option, the output format using the `-t/--to` option.
69Thus, to convert `hello.txt` from Markdown to LaTeX, you could type:
71 pandoc -f markdown -t latex hello.txt
73To convert `hello.html` from HTML to Markdown:
75 pandoc -f html -t markdown hello.html
77Supported input and output formats are listed below under [Options]
78(see `-f` for input formats and `-t` for output formats). You
79can also use `pandoc --list-input-formats` and
80`pandoc --list-output-formats` to print lists of supported
81formats.
83If the input or output format is not specified explicitly, `pandoc`
84will attempt to guess it from the extensions of the filenames.
85Thus, for example,
87 pandoc -o hello.tex hello.txt
89will convert `hello.txt` from Markdown to LaTeX. If no output file
90is specified (so that output goes to *stdout*), or if the output file's
91extension is unknown, the output format will default to HTML.
92If no input file is specified (so that input comes from *stdin*), or
93if the input files' extensions are unknown, the input format will
94be assumed to be Markdown.
96## Character encoding
98Pandoc uses the UTF-8 character encoding for both input and output.
99If your local character encoding is not UTF-8, you
100should pipe input and output through [`iconv`]:
102 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
104Note that in some output formats (such as HTML, LaTeX, ConTeXt,
105RTF, OPML, DocBook, and Texinfo), information about
106the character encoding is included in the document header, which
107will only be included if you use the `-s/--standalone` option.
109[`iconv`]: https://www.gnu.org/software/libiconv/
111## Creating a PDF
113To produce a PDF, specify an output file with a `.pdf` extension:
115 pandoc test.txt -o test.pdf
117By default, pandoc will use LaTeX to create the PDF, which requires
118that a LaTeX engine be installed (see `--pdf-engine` below).
119Alternatively, pandoc can use ConTeXt, roff ms, or HTML as an
120intermediate format. To do this, specify an output file with a
121`.pdf` extension, as before, but add the `--pdf-engine` option
122or `-t context`, `-t html`, or `-t ms` to the command line.
123The tool used to generate the PDF from the intermediate format
124may be specified using `--pdf-engine`.
126You can control the PDF style using variables, depending on
127the intermediate format used: see [variables for LaTeX],
128[variables for ConTeXt], [variables for `wkhtmltopdf`],
129[variables for ms]. When HTML is used as an intermediate
130format, the output can be styled using `--css`.
132To debug the PDF creation, it can be useful to look at the intermediate
133representation: instead of `-o test.pdf`, use for example `-s -o test.tex`
134to output the generated LaTeX. You can then test it with `pdflatex test.tex`.
136When using LaTeX, the following packages need to be available
137(they are included with all recent versions of [TeX Live]):
138[`amsfonts`], [`amsmath`], [`lm`], [`unicode-math`],
139[`ifxetex`], [`ifluatex`], [`listings`] (if the
140`--listings` option is used), [`fancyvrb`], [`longtable`],
141[`booktabs`], [`graphicx`] (if the document
142contains images), [`hyperref`], [`xcolor`],
143[`ulem`], [`geometry`] (with the `geometry` variable set),
144[`setspace`] (with `linestretch`), and
145[`babel`] (with `lang`). The use of `xelatex` or `lualatex` as
146the PDF engine requires [`fontspec`]. `lualatex` uses
147[`selnolig`]. `xelatex` uses [`polyglossia`] (with `lang`),
148[`xecjk`], and [`bidi`] (with the `dir` variable set). If the
149`mathspec` variable is set, `xelatex` will use [`mathspec`]
150instead of [`unicode-math`]. The [`upquote`] and [`microtype`]
151packages are used if available, and [`csquotes`] will be used
152for [typography] if the `csquotes` variable or metadata field is
153set to a true value. The [`natbib`], [`biblatex`], [`bibtex`],
154and [`biber`] packages can optionally be used for [citation
155rendering]. The following packages will be used to improve
156output quality if present, but pandoc does not require them to
157be present: [`upquote`] (for straight quotes in verbatim
158environments), [`microtype`] (for better spacing adjustments),
159[`parskip`] (for better inter-paragraph spaces), [`xurl`] (for
160better line breaks in URLs), [`bookmark`] (for better PDF
161bookmarks), and [`footnotehyper`] or [`footnote`] (to allow
162footnotes in tables).
164[TeX Live]: https://www.tug.org/texlive/
165[`amsfonts`]: https://ctan.org/pkg/amsfonts
166[`amsmath`]: https://ctan.org/pkg/amsmath
167[`babel`]: https://ctan.org/pkg/babel
168[`biber`]: https://ctan.org/pkg/biber
169[`biblatex`]: https://ctan.org/pkg/biblatex
170[`bibtex`]: https://ctan.org/pkg/bibtex
171[`bidi`]: https://ctan.org/pkg/bidi
172[`bookmark`]: https://ctan.org/pkg/bookmark
173[`booktabs`]: https://ctan.org/pkg/booktabs
174[`csquotes`]: https://ctan.org/pkg/csquotes
175[`fancyvrb`]: https://ctan.org/pkg/fancyvrb
176[`fontspec`]: https://ctan.org/pkg/fontspec
177[`footnote`]: https://ctan.org/pkg/footnote
178[`footnotehyper`]: https://ctan.org/pkg/footnotehyper
179[`geometry`]: https://ctan.org/pkg/geometry
180[`graphicx`]: https://ctan.org/pkg/graphicx
181[`grffile`]: https://ctan.org/pkg/grffile
182[`hyperref`]: https://ctan.org/pkg/hyperref
183[`ifluatex`]: https://ctan.org/pkg/ifluatex
184[`ifxetex`]: https://ctan.org/pkg/ifxetex
185[`listings`]: https://ctan.org/pkg/listings
186[`lm`]: https://ctan.org/pkg/lm
187[`longtable`]: https://ctan.org/pkg/longtable
188[`mathspec`]: https://ctan.org/pkg/mathspec
189[`microtype`]: https://ctan.org/pkg/microtype
190[`natbib`]: https://ctan.org/pkg/natbib
191[`parskip`]: https://ctan.org/pkg/parskip
192[`polyglossia`]: https://ctan.org/pkg/polyglossia
193[`prince`]: https://www.princexml.com/
194[`setspace`]: https://ctan.org/pkg/setspace
195[`ulem`]: https://ctan.org/pkg/ulem
196[`unicode-math`]: https://ctan.org/pkg/unicode-math
197[`upquote`]: https://ctan.org/pkg/upquote
198[`weasyprint`]: https://weasyprint.org
199[`wkhtmltopdf`]: https://wkhtmltopdf.org
200[`xcolor`]: https://ctan.org/pkg/xcolor
201[`xecjk`]: https://ctan.org/pkg/xecjk
202[`xurl`]: https://ctan.org/pkg/xurl
203[`selnolig`]: https://ctan.org/pkg/selnolig
207## Reading from the Web
209Instead of an input file, an absolute URI may be given. In this case
210pandoc will fetch the content using HTTP:
212 pandoc -f html -t markdown https://www.fsf.org
214It is possible to supply a custom User-Agent string or other
215header when requesting a document from a URL:
217 pandoc -f html -t markdown --request-header User-Agent:"Mozilla/5.0" \
218 https://www.fsf.org
220# Options
222## General options {.options}
224`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*
226: Specify input format. *FORMAT* can be:
228 ::: {#input-formats}
229 - `bibtex` ([BibTeX] bibliography)
230 - `biblatex` ([BibLaTeX] bibliography)
231 - `commonmark` ([CommonMark] Markdown)
232 - `commonmark_x` ([CommonMark] Markdown with extensions)
233 - `creole` ([Creole 1.0])
234 - `csljson` ([CSL JSON] bibliography)
235 - `csv` ([CSV] table)
236 - `docbook` ([DocBook])
237 - `docx` ([Word docx])
238 - `dokuwiki` ([DokuWiki markup])
239 - `epub` ([EPUB])
240 - `fb2` ([FictionBook2] e-book)
241 - `gfm` ([GitHub-Flavored Markdown]),
242 or the deprecated and less accurate `markdown_github`;
243 use [`markdown_github`](#markdown-variants) only
244 if you need extensions not supported in [`gfm`](#markdown-variants).
245 - `haddock` ([Haddock markup])
246 - `html` ([HTML])
247 - `ipynb` ([Jupyter notebook])
248 - `jats` ([JATS] XML)
249 - `jira` ([Jira]/Confluence wiki markup)
250 - `json` (JSON version of native AST)
251 - `latex` ([LaTeX])
252 - `markdown` ([Pandoc's Markdown])
253 - `markdown_mmd` ([MultiMarkdown])
254 - `markdown_phpextra` ([PHP Markdown Extra])
255 - `markdown_strict` (original unextended [Markdown])
256 - `mediawiki` ([MediaWiki markup])
257 - `man` ([roff man])
258 - `muse` ([Muse])
259 - `native` (native Haskell)
260 - `odt` ([ODT])
261 - `opml` ([OPML])
262 - `org` ([Emacs Org mode])
263 - `rst` ([reStructuredText])
264 - `t2t` ([txt2tags])
265 - `textile` ([Textile])
266 - `tikiwiki` ([TikiWiki markup])
267 - `twiki` ([TWiki markup])
268 - `vimwiki` ([Vimwiki])
269 :::
271 Extensions can be individually enabled or disabled by
272 appending `+EXTENSION` or `-EXTENSION` to the format name.
273 See [Extensions] below, for a list of extensions and
274 their names. See `--list-input-formats` and `--list-extensions`,
275 below.
277`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
279: Specify output format. *FORMAT* can be:
281 ::: {#output-formats}
282 - `asciidoc` ([AsciiDoc]) or `asciidoctor` ([AsciiDoctor])
283 - `beamer` ([LaTeX beamer][`beamer`] slide show)
284 - `commonmark` ([CommonMark] Markdown)
285 - `commonmark_x` ([CommonMark] Markdown with extensions)
286 - `context` ([ConTeXt])
287 - `csljson` ([CSL JSON] bibliography)
288 - `docbook` or `docbook4` ([DocBook] 4)
289 - `docbook5` (DocBook 5)
290 - `docx` ([Word docx])
291 - `dokuwiki` ([DokuWiki markup])
292 - `epub` or `epub3` ([EPUB] v3 book)
293 - `epub2` (EPUB v2)
294 - `fb2` ([FictionBook2] e-book)
295 - `gfm` ([GitHub-Flavored Markdown]),
296 or the deprecated and less accurate `markdown_github`;
297 use [`markdown_github`](#markdown-variants) only
298 if you need extensions not supported in [`gfm`](#markdown-variants).
299 - `haddock` ([Haddock markup])
300 - `html` or `html5` ([HTML], i.e. [HTML5]/XHTML [polyglot markup])
301 - `html4` ([XHTML] 1.0 Transitional)
302 - `icml` ([InDesign ICML])
303 - `ipynb` ([Jupyter notebook])
304 - `jats_archiving` ([JATS] XML, Archiving and Interchange Tag Set)
305 - `jats_articleauthoring` ([JATS] XML, Article Authoring Tag Set)
306 - `jats_publishing` ([JATS] XML, Journal Publishing Tag Set)
307 - `jats` (alias for `jats_archiving`)
308 - `jira` ([Jira]/Confluence wiki markup)
309 - `json` (JSON version of native AST)
310 - `latex` ([LaTeX])
311 - `man` ([roff man])
312 - `markdown` ([Pandoc's Markdown])
313 - `markdown_mmd` ([MultiMarkdown])
314 - `markdown_phpextra` ([PHP Markdown Extra])
315 - `markdown_strict` (original unextended [Markdown])
316 - `mediawiki` ([MediaWiki markup])
317 - `ms` ([roff ms])
318 - `muse` ([Muse]),
319 - `native` (native Haskell),
320 - `odt` ([OpenOffice text document][ODT])
321 - `opml` ([OPML])
322 - `opendocument` ([OpenDocument])
323 - `org` ([Emacs Org mode])
324 - `pdf` ([PDF])
325 - `plain` (plain text),
326 - `pptx` ([PowerPoint] slide show)
327 - `rst` ([reStructuredText])
328 - `rtf` ([Rich Text Format])
329 - `texinfo` ([GNU Texinfo])
330 - `textile` ([Textile])
331 - `slideous` ([Slideous] HTML and JavaScript slide show)
332 - `slidy` ([Slidy] HTML and JavaScript slide show)
333 - `dzslides` ([DZSlides] HTML5 + JavaScript slide show),
334 - `revealjs` ([reveal.js] HTML5 + JavaScript slide show)
335 - `s5` ([S5] HTML and JavaScript slide show)
336 - `tei` ([TEI Simple])
337 - `xwiki` ([XWiki markup])
338 - `zimwiki` ([ZimWiki markup])
339 - the path of a custom Lua writer, see [Custom writers] below
340 :::
342 Note that `odt`, `docx`, `epub`, and `pdf` output will not be directed
343 to *stdout* unless forced with `-o -`.
345 Extensions can be individually enabled or
346 disabled by appending `+EXTENSION` or `-EXTENSION` to the format
347 name. See [Extensions] below, for a list of extensions and their
348 names. See `--list-output-formats` and `--list-extensions`, below.
350`-o` *FILE*, `--output=`*FILE*
352: Write output to *FILE* instead of *stdout*. If *FILE* is
353 `-`, output will go to *stdout*, even if a non-textual format
354 (`docx`, `odt`, `epub2`, `epub3`) is specified.
356`--data-dir=`*DIRECTORY*
358: Specify the user data directory to search for pandoc data files.
359 If this option is not specified, the default user data directory
360 will be used. On \*nix and macOS systems this will be the `pandoc`
361 subdirectory of the XDG data directory (by default,
362 `$HOME/.local/share`, overridable by setting the `XDG_DATA_HOME`
363 environment variable). If that directory does not exist,
364 `$HOME/.pandoc` will be used (for backwards compatibility).
365 In Windows the default user data directory is
366 `C:\Users\USERNAME\AppData\Roaming\pandoc`.
367 You can find the default user data directory on your system by
368 looking at the output of `pandoc --version`.
369 A `reference.odt`, `reference.docx`, `epub.css`, `templates`,
370 `slidy`, `slideous`, or `s5` directory
371 placed in this directory will override pandoc's normal defaults.
373`-d` *FILE*, `--defaults=`*FILE*
375: Specify a set of default option settings. *FILE* is a YAML
376 file whose fields correspond to command-line option
377 settings. All options for document conversion, including input
378 and output files, can be set using a defaults file. The file will
379 be searched for first in the working directory, and then in
380 the `defaults` subdirectory of the user data directory
381 (see `--data-dir`). The `.yaml` extension may be omitted.
382 See the section [Default files] for more information on the
383 file format. Settings from the defaults file may be
384 overridden or extended by subsequent options on the command
385 line.
387`--bash-completion`
389: Generate a bash completion script. To enable bash completion
390 with pandoc, add this to your `.bashrc`:
392 eval "$(pandoc --bash-completion)"
394`--verbose`
396: Give verbose debugging output.
398`--quiet`
400: Suppress warning messages.
402`--fail-if-warnings`
404: Exit with error status if there are any warnings.
406`--log=`*FILE*
408: Write log messages in machine-readable JSON format to
409 *FILE*. All messages above DEBUG level will be written,
410 regardless of verbosity settings (`--verbose`, `--quiet`).
412`--list-input-formats`
414: List supported input formats, one per line.
416`--list-output-formats`
418: List supported output formats, one per line.
420`--list-extensions`[`=`*FORMAT*]
422: List supported extensions for *FORMAT*, one per line, preceded
423 by a `+` or `-` indicating whether it is enabled by default
424 in *FORMAT*. If *FORMAT* is not specified, defaults for
425 pandoc's Markdown are given.
427`--list-highlight-languages`
429: List supported languages for syntax highlighting, one per
430 line.
432`--list-highlight-styles`
434: List supported styles for syntax highlighting, one per line.
435 See `--highlight-style`.
437`-v`, `--version`
439: Print version.
441`-h`, `--help`
443: Show usage message.
445[Markdown]: https://daringfireball.net/projects/markdown/
446[CommonMark]: https://commonmark.org
447[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/
448[GitHub-Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/
449[MultiMarkdown]: https://fletcherpenney.net/multimarkdown/
450[reStructuredText]: https://docutils.sourceforge.io/docs/ref/rst/introduction.html
451[S5]: https://meyerweb.com/eric/tools/s5/
452[Slidy]: https://www.w3.org/Talks/Tools/Slidy2/
453[Slideous]: https://goessner.net/articles/slideous/
454[HTML]: https://www.w3.org/html/
455[HTML5]: https://html.spec.whatwg.org/
456[polyglot markup]: https://www.w3.org/TR/html-polyglot/
457[XHTML]: https://www.w3.org/TR/xhtml1/
458[LaTeX]: https://www.latex-project.org/
459[`beamer`]: https://ctan.org/pkg/beamer
460[Beamer User's Guide]: http://mirrors.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf
461[ConTeXt]: https://www.contextgarden.net/
462[Rich Text Format]: https://en.wikipedia.org/wiki/Rich_Text_Format
463[DocBook]: https://docbook.org
464[JATS]: https://jats.nlm.nih.gov
465[Jira]: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all
466[txt2tags]: https://txt2tags.org
467[EPUB]: http://idpf.org/epub
468[OPML]: http://dev.opml.org/spec2.html
469[OpenDocument]: http://opendocument.xml.org
470[ODT]: https://en.wikipedia.org/wiki/OpenDocument
471[Textile]: https://www.promptworks.com/textile
472[MediaWiki markup]: https://www.mediawiki.org/wiki/Help:Formatting
473[DokuWiki markup]: https://www.dokuwiki.org/dokuwiki
474[ZimWiki markup]: https://zim-wiki.org/manual/Help/Wiki_Syntax.html
475[XWiki markup]: https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiSyntax/
476[TWiki markup]: https://twiki.org/cgi-bin/view/TWiki/TextFormattingRules
477[TikiWiki markup]: https://doc.tiki.org/Wiki-Syntax-Text#The_Markup_Language_Wiki-Syntax
478[Haddock markup]: https://www.haskell.org/haddock/doc/html/ch03s08.html
479[Creole 1.0]: http://www.wikicreole.org/wiki/Creole1.0
480[CSV]: https://tools.ietf.org/html/rfc4180
481[roff man]: https://man.cx/groff_man(7)
482[roff ms]: https://man.cx/groff_ms(7)
483[Haskell]: https://www.haskell.org
484[GNU Texinfo]: https://www.gnu.org/software/texinfo/
485[Emacs Org mode]: https://orgmode.org
486[AsciiDoc]: https://www.methods.co.nz/asciidoc/
487[AsciiDoctor]: https://asciidoctor.org/
488[DZSlides]: http://paulrouget.com/dzslides/
489[Word docx]: https://en.wikipedia.org/wiki/Office_Open_XML
490[PDF]: https://www.adobe.com/pdf/
491[reveal.js]: https://revealjs.com/
492[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1
493[Jupyter notebook]: https://nbformat.readthedocs.io/en/latest/
494[InDesign ICML]: https://wwwimages.adobe.com/www.adobe.com/content/dam/acom/en/devnet/indesign/sdk/cs6/idml/idml-cookbook.pdf
495[TEI Simple]: https://github.com/TEIC/TEI-Simple
496[Muse]: https://amusewiki.org/library/manual
497[PowerPoint]: https://en.wikipedia.org/wiki/Microsoft_PowerPoint
498[Vimwiki]: https://vimwiki.github.io
499[CSL JSON]: https://citeproc-js.readthedocs.io/en/latest/csl-json/markup.html
500[BibTeX]: https://ctan.org/pkg/bibtex
501[BibLaTeX]: https://ctan.org/pkg/biblatex
503## Reader options {.options}
505`--shift-heading-level-by=`*NUMBER*
507: Shift heading levels by a positive or negative integer.
508 For example, with `--shift-heading-level-by=-1`, level 2
509 headings become level 1 headings, and level 3 headings
510 become level 2 headings. Headings cannot have a level
511 less than 1, so a heading that would be shifted below level 1
512 becomes a regular paragraph. Exception: with a shift of -N,
513 a level-N heading at the beginning of the document
514 replaces the metadata title. `--shift-heading-level-by=-1`
515 is a good choice when converting HTML or Markdown documents that
516 use an initial level-1 heading for the document title and
517 level-2+ headings for sections. `--shift-heading-level-by=1`
518 may be a good choice for converting Markdown documents that
519 use level-1 headings for sections to HTML, since pandoc uses
520 a level-1 heading to render the document title.
522`--base-header-level=`*NUMBER*
524: *Deprecated. Use `--shift-heading-level-by`=X instead,
525 where X = NUMBER - 1.* Specify the base level for headings
526 (defaults to 1).
528`--strip-empty-paragraphs`
530: *Deprecated. Use the `+empty_paragraphs` extension instead.*
531 Ignore paragraphs with no content. This option is useful
532 for converting word processing documents where users have
533 used empty paragraphs to create inter-paragraph space.
535`--indented-code-classes=`*CLASSES*
537: Specify classes to use for indented code blocks--for example,
538 `perl,numberLines` or `haskell`. Multiple classes may be separated
539 by spaces or commas.
541`--default-image-extension=`*EXTENSION*
543: Specify a default extension to use when image paths/URLs have no
544 extension. This allows you to use the same source for formats that
545 require different kinds of images. Currently this option only affects
546 the Markdown and LaTeX readers.
548`--file-scope`
550: Parse each file individually before combining for multifile
551 documents. This will allow footnotes in different files with the
552 same identifiers to work as expected. If this option is set,
553 footnotes and links will not work across files. Reading binary
554 files (docx, odt, epub) implies `--file-scope`.
556`-F` *PROGRAM*, `--filter=`*PROGRAM*
558: Specify an executable to be used as a filter transforming the
559 pandoc AST after the input is parsed and before the output is
560 written. The executable should read JSON from stdin and write
561 JSON to stdout. The JSON must be formatted like pandoc's own
562 JSON input and output. The name of the output format will be
563 passed to the filter as the first argument. Hence,
565 pandoc --filter ./caps.py -t latex
567 is equivalent to
569 pandoc -t json | ./caps.py latex | pandoc -f json -t latex
571 The latter form may be useful for debugging filters.
573 Filters may be written in any language. `Text.Pandoc.JSON`
574 exports `toJSONFilter` to facilitate writing filters in Haskell.
575 Those who would prefer to write filters in python can use the
576 module [`pandocfilters`], installable from PyPI. There are also
577 pandoc filter libraries in [PHP], [perl], and
578 [JavaScript/node.js].
580 In order of preference, pandoc will look for filters in
582 1. a specified full or relative path (executable or
583 non-executable)
585 2. `$DATADIR/filters` (executable or non-executable)
586 where `$DATADIR` is the user data directory (see
587 `--data-dir`, above).
589 3. `$PATH` (executable only)
591 Filters and Lua-filters are applied in the order specified
592 on the command line.
594`-L` *SCRIPT*, `--lua-filter=`*SCRIPT*
596: Transform the document in a similar fashion as JSON filters (see
597 `--filter`), but use pandoc's built-in Lua filtering system. The given
598 Lua script is expected to return a list of Lua filters which will be
599 applied in order. Each Lua filter must contain element-transforming
600 functions indexed by the name of the AST element on which the filter
601 function should be applied.
603 The `pandoc` Lua module provides helper functions for element
604 creation. It is always loaded into the script's Lua environment.
606 The following is an example Lua script for macro-expansion:
608 function expand_hello_world(inline)
609 if inline.c == '{{helloworld}}' then
610 return pandoc.Emph{ pandoc.Str "Hello, World" }
611 else
612 return inline
613 end
614 end
616 return {{Str = expand_hello_world}}
618 In order of preference, pandoc will look for Lua filters in
620 1. a specified full or relative path (executable or
621 non-executable)
623 2. `$DATADIR/filters` (executable or non-executable)
624 where `$DATADIR` is the user data directory (see
625 `--data-dir`, above).
627`-M` *KEY*[`=`*VAL*], `--metadata=`*KEY*[`:`*VAL*]
629: Set the metadata field *KEY* to the value *VAL*. A value specified
630 on the command line overrides a value specified in the document
631 using [YAML metadata blocks][Extension: `yaml_metadata_block`].
632 Values will be parsed as YAML boolean or string values. If no value is
633 specified, the value will be treated as Boolean true. Like
634 `--variable`, `--metadata` causes template variables to be set.
635 But unlike `--variable`, `--metadata` affects the metadata of the
636 underlying document (which is accessible from filters and may be
637 printed in some output formats) and metadata values will be escaped
638 when inserted into the template.
640`--metadata-file=`*FILE*
642: Read metadata from the supplied YAML (or JSON) file. This
643 option can be used with every input format, but string scalars
644 in the YAML file will always be parsed as Markdown. Generally,
645 the input will be handled the same as in [YAML metadata
646 blocks][Extension: `yaml_metadata_block`]. This option can be
647 used repeatedly to include multiple metadata files; values in
648 files specified later on the command line will be preferred
649 over those specified in earlier files. Metadata values
650 specified inside the document, or by using `-M`, overwrite
651 values specified with this option.
653`-p`, `--preserve-tabs`
655: Preserve tabs instead of converting them to spaces. (By default, pandoc
656 converts tabs to spaces before parsing its input.) Note that this will
657 only affect tabs in literal code spans and code blocks. Tabs in regular
658 text are always treated as spaces.
660`--tab-stop=`*NUMBER*
662: Specify the number of spaces per tab (default is 4).
664`--track-changes=accept`|`reject`|`all`
666: Specifies what to do with insertions, deletions, and comments
667 produced by the MS Word "Track Changes" feature. `accept` (the
668 default), inserts all insertions, and ignores all
669 deletions. `reject` inserts all deletions and ignores
670 insertions. Both `accept` and `reject` ignore comments. `all` puts
671 in insertions, deletions, and comments, wrapped in spans with
672 `insertion`, `deletion`, `comment-start`, and `comment-end`
673 classes, respectively. The author and time of change is
674 included. `all` is useful for scripting: only accepting changes
675 from a certain reviewer, say, or before a certain date. If a
676 paragraph is inserted or deleted, `track-changes=all` produces a
677 span with the class `paragraph-insertion`/`paragraph-deletion`
678 before the affected paragraph break. This option only affects the
679 docx reader.
681`--extract-media=`*DIR*
683: Extract images and other media contained in or linked from
684 the source document to the path *DIR*, creating it if
685 necessary, and adjust the images references in the document
686 so they point to the extracted files. If the source format is
687 a binary container (docx, epub, or odt), the media is
688 extracted from the container and the original
689 filenames are used. Otherwise the media is read from the
690 file system or downloaded, and new filenames are constructed
691 based on SHA1 hashes of the contents.
693`--abbreviations=`*FILE*
695: Specifies a custom abbreviations file, with abbreviations
696 one to a line. If this option is not specified, pandoc will
697 read the data file `abbreviations` from the user data
698 directory or fall back on a system default. To see the
699 system default, use
700 `pandoc --print-default-data-file=abbreviations`. The only
701 use pandoc makes of this list is in the Markdown reader.
702 Strings ending in a period that are found in this list will
703 be followed by a nonbreaking space, so that the period will
704 not produce sentence-ending space in formats like LaTeX.
706[`pandocfilters`]: https://github.com/jgm/pandocfilters
707[PHP]: https://github.com/vinai/pandocfilters-php
708[perl]: https://metacpan.org/pod/Pandoc::Filter
709[JavaScript/node.js]: https://github.com/mvhenderson/pandoc-filter-node
711## General writer options {.options}
713`-s`, `--standalone`
715: Produce output with an appropriate header and footer (e.g. a
716 standalone HTML, LaTeX, TEI, or RTF file, not a fragment). This option
717 is set automatically for `pdf`, `epub`, `epub3`, `fb2`, `docx`, and `odt`
718 output. For `native` output, this option causes metadata to
719 be included; otherwise, metadata is suppressed.
721`--template=`*FILE*|*URL*
723: Use the specified file as a custom template for the generated document.
724 Implies `--standalone`. See [Templates], below, for a description
725 of template syntax. If no extension is specified, an extension
726 corresponding to the writer will be added, so that `--template=special`
727 looks for `special.html` for HTML output. If the template is not
728 found, pandoc will search for it in the `templates` subdirectory of
729 the user data directory (see `--data-dir`). If this option is not used,
730 a default template appropriate for the output format will be used (see
731 `-D/--print-default-template`).
733`-V` *KEY*[`=`*VAL*], `--variable=`*KEY*[`:`*VAL*]
735: Set the template variable *KEY* to the value *VAL* when rendering the
736 document in standalone mode. If no *VAL* is specified, the
737 key will be given the value `true`.
739`-D` *FORMAT*, `--print-default-template=`*FORMAT*
741: Print the system default template for an output *FORMAT*. (See `-t`
742 for a list of possible *FORMAT*s.) Templates in the user data
743 directory are ignored. This option may be used with
744 `-o`/`--output` to redirect output to a file, but
745 `-o`/`--output` must come before `--print-default-template`
746 on the command line.
748 Note that some of the default templates use partials, for
749 example `styles.html`. To print the partials, use
750 `--print-default-data-file`: for example,
751 `--print-default-data-file=templates/styles.html`.
753`--print-default-data-file=`*FILE*
755: Print a system default data file. Files in the user data directory
756 are ignored. This option may be used with `-o`/`--output` to
757 redirect output to a file, but `-o`/`--output` must come before
758 `--print-default-data-file` on the command line.
760`--eol=crlf`|`lf`|`native`
762: Manually specify line endings: `crlf` (Windows), `lf`
763 (macOS/Linux/UNIX), or `native` (line endings appropriate
764 to the OS on which pandoc is being run). The default is
765 `native`.
767`--dpi`=*NUMBER*
769: Specify the default dpi (dots per inch) value for conversion
770 from pixels to inch/centimeters and vice versa. (Technically,
771 the correct term would be ppi: pixels per inch.) The default
772 is 96dpi. When images contain information about dpi
773 internally, the encoded value is used instead of the default
774 specified by this option.
776`--wrap=auto`|`none`|`preserve`
778: Determine how text is wrapped in the output (the source
779 code, not the rendered version). With `auto` (the default),
780 pandoc will attempt to wrap lines to the column width specified by
781 `--columns` (default 72). With `none`, pandoc will not wrap
782 lines at all. With `preserve`, pandoc will attempt to
783 preserve the wrapping from the source document (that is,
784 where there are nonsemantic newlines in the source, there
785 will be nonsemantic newlines in the output as well).
786 Automatic wrapping does not currently work in HTML output.
787 In `ipynb` output, this option affects wrapping of the
788 contents of markdown cells.
790`--columns=`*NUMBER*
792: Specify length of lines in characters. This affects text wrapping
793 in the generated source code (see `--wrap`). It also affects
794 calculation of column widths for plain text tables (see [Tables] below).
796`--toc`, `--table-of-contents`
798: Include an automatically generated table of contents (or, in
799 the case of `latex`, `context`, `docx`, `odt`,
800 `opendocument`, `rst`, or `ms`, an instruction to create
801 one) in the output document. This option has no effect
802 unless `-s/--standalone` is used, and it has no effect
803 on `man`, `docbook4`, `docbook5`, or `jats` output.
805 Note that if you are producing a PDF via `ms`, the table
806 of contents will appear at the beginning of the
807 document, before the title. If you would prefer it to
808 be at the end of the document, use the option
809 `--pdf-engine-opt=--no-toc-relocation`.
811`--toc-depth=`*NUMBER*
813: Specify the number of section levels to include in the table
814 of contents. The default is 3 (which means that level-1, 2, and 3
815 headings will be listed in the contents).
817`--strip-comments`
819: Strip out HTML comments in the Markdown or Textile source,
820 rather than passing them on to Markdown, Textile or HTML
821 output as raw HTML. This does not apply to HTML comments
822 inside raw HTML blocks when the `markdown_in_html_blocks`
823 extension is not set.
825`--no-highlight`
827: Disables syntax highlighting for code blocks and inlines, even when
828 a language attribute is given.
830`--highlight-style=`*STYLE*|*FILE*
832: Specifies the coloring style to be used in highlighted source code.
833 Options are `pygments` (the default), `kate`, `monochrome`,
834 `breezeDark`, `espresso`, `zenburn`, `haddock`, and `tango`.
835 For more information on syntax highlighting in pandoc, see
836 [Syntax highlighting], below. See also
837 `--list-highlight-styles`.
839 Instead of a *STYLE* name, a JSON file with extension
840 `.theme` may be supplied. This will be parsed as a KDE
841 syntax highlighting theme and (if valid) used as the
842 highlighting style.
844 To generate the JSON version of an existing style,
845 use `--print-highlight-style`.
847`--print-highlight-style=`*STYLE*|*FILE*
849: Prints a JSON version of a highlighting style, which can
850 be modified, saved with a `.theme` extension, and used
851 with `--highlight-style`. This option may be used with
852 `-o`/`--output` to redirect output to a file, but
853 `-o`/`--output` must come before `--print-highlight-style`
854 on the command line.
856`--syntax-definition=`*FILE*
858: Instructs pandoc to load a KDE XML syntax definition file,
859 which will be used for syntax highlighting of appropriately
860 marked code blocks. This can be used to add support for
861 new languages or to use altered syntax definitions for
862 existing languages. This option may be repeated to add
863 multiple syntax definitions.
865`-H` *FILE*, `--include-in-header=`*FILE*|*URL*
867: Include contents of *FILE*, verbatim, at the end of the header.
868 This can be used, for example, to include special
869 CSS or JavaScript in HTML documents. This option can be used
870 repeatedly to include multiple files in the header. They will be
871 included in the order specified. Implies `--standalone`.
873`-B` *FILE*, `--include-before-body=`*FILE*|*URL*
875: Include contents of *FILE*, verbatim, at the beginning of the
876 document body (e.g. after the `<body>` tag in HTML, or the
877 `\begin{document}` command in LaTeX). This can be used to include
878 navigation bars or banners in HTML documents. This option can be
879 used repeatedly to include multiple files. They will be included in
880 the order specified. Implies `--standalone`.
882`-A` *FILE*, `--include-after-body=`*FILE*|*URL*
884: Include contents of *FILE*, verbatim, at the end of the document
885 body (before the `</body>` tag in HTML, or the
886 `\end{document}` command in LaTeX). This option can be used
887 repeatedly to include multiple files. They will be included in the
888 order specified. Implies `--standalone`.
890`--resource-path=`*SEARCHPATH*
892: List of paths to search for images and other resources.
893 The paths should be separated by `:` on Linux, UNIX, and
894 macOS systems, and by `;` on Windows. If `--resource-path`
895 is not specified, the default resource path is the working
896 directory. Note that, if `--resource-path` is specified,
897 the working directory must be explicitly listed or it
898 will not be searched. For example:
899 `--resource-path=.:test` will search the working directory
900 and the `test` subdirectory, in that order.
902 `--resource-path` only has an effect if (a) the output
903 format embeds images (for example, `docx`, `pdf`, or `html`
904 with `--self-contained`) or (b) it is used together with
905 `--extract-media`.
907`--request-header=`*NAME*`:`*VAL*
909: Set the request header *NAME* to the value *VAL* when making
910 HTTP requests (for example, when a URL is given on the
911 command line, or when resources used in a document must be
912 downloaded). If you're behind a proxy, you also need to set
913 the environment variable `http_proxy` to `http://...`.
915`--no-check-certificate`
917: Disable the certificate verification to allow access to
918 unsecure HTTP resources (for example when the certificate
919 is no longer valid or self signed).
921## Options affecting specific writers {.options}
923`--self-contained`
925: Produce a standalone HTML file with no external dependencies, using
926 `data:` URIs to incorporate the contents of linked scripts, stylesheets,
927 images, and videos. Implies `--standalone`. The resulting file should be
928 "self-contained," in the sense that it needs no external files and no net
929 access to be displayed properly by a browser. This option works only with
930 HTML output formats, including `html4`, `html5`, `html+lhs`, `html5+lhs`,
931 `s5`, `slidy`, `slideous`, `dzslides`, and `revealjs`. Scripts, images,
932 and stylesheets at absolute URLs will be downloaded; those at relative
933 URLs will be sought relative to the working directory (if the first source
934 file is local) or relative to the base URL (if the first source
935 file is remote). Elements with the attribute
936 `data-external="1"` will be left alone; the documents they
937 link to will not be incorporated in the document.
938 Limitation: resources that are loaded dynamically through
939 JavaScript cannot be incorporated; as a result,
940 `--self-contained` does not work with `--mathjax`, and some
941 advanced features (e.g. zoom or speaker notes) may not work
942 in an offline "self-contained" `reveal.js` slide show.
944`--html-q-tags`
946: Use `<q>` tags for quotes in HTML. (This option only has an
947 effect if the `smart` extension is enabled for the input
948 format used.)
950`--ascii`
952: Use only ASCII characters in output. Currently supported for XML
953 and HTML formats (which use entities instead of UTF-8 when this
954 option is selected), CommonMark, gfm, and Markdown (which use
955 entities), roff ms (which use hexadecimal escapes), and to a
956 limited degree LaTeX (which uses standard commands for accented
957 characters when possible). roff man output uses ASCII by default.
959`--reference-links`
961: Use reference-style links, rather than inline links, in writing Markdown
962 or reStructuredText. By default inline links are used. The
963 placement of link references is affected by the
964 `--reference-location` option.
966`--reference-location = block`|`section`|`document`
968: Specify whether footnotes (and references, if `reference-links` is
969 set) are placed at the end of the current (top-level) block, the
970 current section, or the document. The default is
971 `document`. Currently only affects the markdown writer.
973`--atx-headers`
975: Use ATX-style headings in Markdown output. The default is
976 to use setext-style headings for levels 1 to 2, and then ATX headings.
977 (Note: for `gfm` output, ATX headings are always used.)
978 This option also affects markdown cells in `ipynb` output.
980`--top-level-division=[default|section|chapter|part]`
982: Treat top-level headings as the given division type in LaTeX, ConTeXt,
983 DocBook, and TEI output. The hierarchy order is part, chapter, then section;
984 all headings are shifted such that the top-level heading becomes the specified
985 type. The default behavior is to determine the best division type via
986 heuristics: unless other conditions apply, `section` is chosen. When the
987 `documentclass` variable is set to `report`, `book`, or `memoir` (unless the
988 `article` option is specified), `chapter` is implied as the setting for this
989 option. If `beamer` is the output format, specifying either `chapter` or
990 `part` will cause top-level headings to become `\part{..}`, while
991 second-level headings remain as their default type.
993`-N`, `--number-sections`
995: Number section headings in LaTeX, ConTeXt, HTML, Docx, or EPUB output.
996 By default, sections are not numbered. Sections with class
997 `unnumbered` will never be numbered, even if `--number-sections`
998 is specified.
1000`--number-offset=`*NUMBER*[`,`*NUMBER*`,`*...*]
1002: Offset for section headings in HTML output (ignored in other
1003 output formats). The first number is added to the section number for
1004 top-level headings, the second for second-level headings, and so on.
1005 So, for example, if you want the first top-level heading in your
1006 document to be numbered "6", specify `--number-offset=5`.
1007 If your document starts with a level-2 heading which you want to
1008 be numbered "1.5", specify `--number-offset=1,4`.
1009 Offsets are 0 by default. Implies `--number-sections`.
1011`--listings`
1013: Use the [`listings`] package for LaTeX code blocks. The package
1014 does not support multi-byte encoding for source code. To handle UTF-8
1015 you would need to use a custom template. This issue is fully
1016 documented here: [Encoding issue with the listings package].
1018`-i`, `--incremental`
1020: Make list items in slide shows display incrementally (one by one).
1021 The default is for lists to be displayed all at once.
1023`--slide-level=`*NUMBER*
1025: Specifies that headings with the specified level create
1026 slides (for `beamer`, `s5`, `slidy`, `slideous`, `dzslides`). Headings
1027 above this level in the hierarchy are used to divide the
1028 slide show into sections; headings below this level create
1029 subheads within a slide. Note that content that is
1030 not contained under slide-level headings will not appear in
1031 the slide show. The default is to set the slide level based
1032 on the contents of the document; see [Structuring the slide
1033 show].
1035`--section-divs`
1037: Wrap sections in `<section>` tags (or `<div>` tags for `html4`),
1038 and attach identifiers to the enclosing `<section>` (or `<div>`)
1039 rather than the heading itself. See
1040 [Heading identifiers], below.
1042`--email-obfuscation=none`|`javascript`|`references`
1044: Specify a method for obfuscating `mailto:` links in HTML documents.
1045 `none` leaves `mailto:` links as they are. `javascript` obfuscates
1046 them using JavaScript. `references` obfuscates them by printing their
1047 letters as decimal or hexadecimal character references. The default
1048 is `none`.
1050`--id-prefix=`*STRING*
1052: Specify a prefix to be added to all identifiers and internal links
1053 in HTML and DocBook output, and to footnote numbers in Markdown
1054 and Haddock output. This is useful for preventing duplicate
1055 identifiers when generating fragments to be included in other pages.
1057`-T` *STRING*, `--title-prefix=`*STRING*
1059: Specify *STRING* as a prefix at the beginning of the title
1060 that appears in the HTML header (but not in the title as it
1061 appears at the beginning of the HTML body). Implies `--standalone`.
1063`-c` *URL*, `--css=`*URL*
1065: Link to a CSS style sheet. This option can be used repeatedly to
1066 include multiple files. They will be included in the order specified.
1068 A stylesheet is required for generating EPUB. If none is
1069 provided using this option (or the `css` or `stylesheet`
1070 metadata fields), pandoc will look for a file `epub.css` in the
1071 user data directory (see `--data-dir`). If it is not
1072 found there, sensible defaults will be used.
1074`--reference-doc=`*FILE*
1076: Use the specified file as a style reference in producing a
1077 docx or ODT file.
1079 Docx
1081 : For best results, the reference docx should be a modified
1082 version of a docx file produced using pandoc. The contents
1083 of the reference docx are ignored, but its stylesheets and
1084 document properties (including margins, page size, header,
1085 and footer) are used in the new docx. If no reference docx
1086 is specified on the command line, pandoc will look for a
1087 file `reference.docx` in the user data directory (see
1088 `--data-dir`). If this is not found either, sensible
1089 defaults will be used.
1091 To produce a custom `reference.docx`, first get a copy of
1092 the default `reference.docx`: `pandoc
1093 -o custom-reference.docx --print-default-data-file reference.docx`.
1094 Then open `custom-reference.docx` in Word, modify the
1095 styles as you wish, and save the file. For best
1096 results, do not make changes to this file other than
1097 modifying the styles used by pandoc:
1099 Paragraph styles:
1101 - Normal
1102 - Body Text
1103 - First Paragraph
1104 - Compact
1105 - Title
1106 - Subtitle
1107 - Author
1108 - Date
1109 - Abstract
1110 - Bibliography
1111 - Heading 1
1112 - Heading 2
1113 - Heading 3
1114 - Heading 4
1115 - Heading 5
1116 - Heading 6
1117 - Heading 7
1118 - Heading 8
1119 - Heading 9
1120 - Block Text
1121 - Footnote Text
1122 - Definition Term
1123 - Definition
1124 - Caption
1125 - Table Caption
1126 - Image Caption
1127 - Figure
1128 - Captioned Figure
1129 - TOC Heading
1131 Character styles:
1133 - Default Paragraph Font
1134 - Body Text Char
1135 - Verbatim Char
1136 - Footnote Reference
1137 - Hyperlink
1138 - Section Number
1140 Table style:
1142 - Table
1144 ODT
1146 : For best results, the reference ODT should be a modified
1147 version of an ODT produced using pandoc. The contents of
1148 the reference ODT are ignored, but its stylesheets are used
1149 in the new ODT. If no reference ODT is specified on the
1150 command line, pandoc will look for a file `reference.odt` in
1151 the user data directory (see `--data-dir`). If this is not
1152 found either, sensible defaults will be used.
1154 To produce a custom `reference.odt`, first get a copy of
1155 the default `reference.odt`: `pandoc
1156 -o custom-reference.odt --print-default-data-file reference.odt`.
1157 Then open `custom-reference.odt` in LibreOffice, modify
1158 the styles as you wish, and save the file.
1160 PowerPoint
1162 : Templates included with Microsoft PowerPoint 2013 (either with
1163 `.pptx` or `.potx` extension) are known to work, as are most
1164 templates derived from these.
1166 The specific requirement is that the template should begin with
1167 the following first four layouts:
1169 1. Title Slide
1170 2. Title and Content
1171 3. Section Header
1172 4. Two Content
1174 All templates included with a recent version of MS PowerPoint
1175 will fit these criteria. (You can click on `Layout` under the
1176 `Home` menu to check.)
1178 You can also modify the default `reference.pptx`: first run
1179 `pandoc -o custom-reference.pptx --print-default-data-file
1180 reference.pptx`, and then modify `custom-reference.pptx`
1181 in MS PowerPoint (pandoc will use the first four layout
1182 slides, as mentioned above).
1184`--epub-cover-image=`*FILE*
1186: Use the specified image as the EPUB cover. It is recommended
1187 that the image be less than 1000px in width and height. Note that
1188 in a Markdown source document you can also specify `cover-image`
1189 in a YAML metadata block (see [EPUB Metadata], below).
1191`--epub-metadata=`*FILE*
1193: Look in the specified XML file for metadata for the EPUB.
1194 The file should contain a series of [Dublin Core elements].
1195 For example:
1197 <dc:rights>Creative Commons</dc:rights>
1198 <dc:language>es-AR</dc:language>
1200 By default, pandoc will include the following metadata elements:
1201 `<dc:title>` (from the document title), `<dc:creator>` (from the
1202 document authors), `<dc:date>` (from the document date, which should
1203 be in [ISO 8601 format]), `<dc:language>` (from the `lang`
1204 variable, or, if is not set, the locale), and `<dc:identifier
1205 id="BookId">` (a randomly generated UUID). Any of these may be
1206 overridden by elements in the metadata file.
1208 Note: if the source document is Markdown, a YAML metadata block
1209 in the document can be used instead. See below under
1210 [EPUB Metadata].
1212`--epub-embed-font=`*FILE*
1214: Embed the specified font in the EPUB. This option can be repeated
1215 to embed multiple fonts. Wildcards can also be used: for example,
1216 `DejaVuSans-*.ttf`. However, if you use wildcards on the command
1217 line, be sure to escape them or put the whole filename in single quotes,
1218 to prevent them from being interpreted by the shell. To use the
1219 embedded fonts, you will need to add declarations like the following
1220 to your CSS (see `--css`):
1222 @font-face {
1223 font-family: DejaVuSans;
1224 font-style: normal;
1225 font-weight: normal;
1226 src:url("DejaVuSans-Regular.ttf");
1228 @font-face {
1229 font-family: DejaVuSans;
1230 font-style: normal;
1231 font-weight: bold;
1232 src:url("DejaVuSans-Bold.ttf");
1234 @font-face {
1235 font-family: DejaVuSans;
1236 font-style: italic;
1237 font-weight: normal;
1238 src:url("DejaVuSans-Oblique.ttf");
1240 @font-face {
1241 font-family: DejaVuSans;
1242 font-style: italic;
1243 font-weight: bold;
1244 src:url("DejaVuSans-BoldOblique.ttf");
1246 body { font-family: "DejaVuSans"; }
1248`--epub-chapter-level=`*NUMBER*
1250: Specify the heading level at which to split the EPUB into separate
1251 "chapter" files. The default is to split into chapters at level-1
1252 headings. This option only affects the internal composition of the
1253 EPUB, not the way chapters and sections are displayed to users. Some
1254 readers may be slow if the chapter files are too large, so for large
1255 documents with few level-1 headings, one might want to use a chapter
1256 level of 2 or 3.
1258`--epub-subdirectory=`*DIRNAME*
1260: Specify the subdirectory in the OCF container that is to hold
1261 the EPUB-specific contents. The default is `EPUB`. To put
1262 the EPUB contents in the top level, use an empty string.
1264`--ipynb-output=all|none|best`
1266: Determines how ipynb output cells are treated. `all` means
1267 that all of the data formats included in the original are
1268 preserved. `none` means that the contents of data cells
1269 are omitted. `best` causes pandoc to try to pick the
1270 richest data block in each output cell that is compatible
1271 with the output format. The default is `best`.
1273`--pdf-engine=`*PROGRAM*
1275: Use the specified engine when producing PDF output.
1276 Valid values are `pdflatex`, `lualatex`, `xelatex`, `latexmk`,
1277 `tectonic`, `wkhtmltopdf`, `weasyprint`, `prince`, `context`,
1278 and `pdfroff`. If the engine is not in your PATH, the full
1279 path of the engine may be specified here. If this option
1280 is not specified, pandoc uses the following defaults
1281 depending on the output format specified using `-t/--to`:
1283 - `-t latex` or none: `pdflatex` (other options: `xelatex`, `lualatex`,
1284 `tectonic`, `latexmk`)
1285 - `-t context`: `context`
1286 - `-t html`: `wkhtmltopdf` (other options: `prince`, `weasyprint`;
1287 see [print-css.rocks](https://print-css.rocks) for a good
1288 introduction to PDF generation from HTML/CSS.)
1289 - `-t ms`: `pdfroff`
1291`--pdf-engine-opt=`*STRING*
1293: Use the given string as a command-line argument to the `pdf-engine`.
1294 For example, to use a persistent directory `foo` for `latexmk`'s
1295 auxiliary files, use `--pdf-engine-opt=-outdir=foo`.
1296 Note that no check for duplicate options is done.
1298[Dublin Core elements]: https://www.dublincore.org/specifications/dublin-core/dces/
1299[ISO 8601 format]: https://www.w3.org/TR/NOTE-datetime
1300[Encoding issue with the listings package]:
1301 https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings#Encoding_issue
1303## Citation rendering {.options}
1305`-C`, `--citeproc`
1307: Process the citations in the file, replacing them with
1308 rendered citations and adding a bibliography.
1309 Citation processing will not take place unless bibliographic
1310 data is supplied, either through an external file specified
1311 using the `--bibliography` option or the `bibliography`
1312 field in metadata, or via a `references` section in metadata
1313 containing a list of citations in CSL YAML format with
1314 Markdown formatting. The style is controlled by a [CSL]
1315 stylesheet specified using the `--csl` option or the `csl`
1316 field in metadata. (If no stylesheet is specified,
1317 the `chicago-author-date` style will be used by default.)
1318 The citation processing transformation may be applied before
1319 or after filters or Lua filters (see `--filter`,
1320 `--lua-filter`): these transformations are applied in the
1321 order they appear on the command line. For more
1322 information, see the section on [Citations].
1324`--bibliography=`*FILE*
1326: Set the `bibliography` field in the document's metadata to *FILE*,
1327 overriding any value set in the metadata. If you supply
1328 this argument multiple times, each *FILE* will be added to
1329 bibliography.
1331`--csl=`*FILE*
1333: Set the `csl` field in the document's metadata to *FILE*,
1334 overriding any value set in the metadata. (This is equivalent to
1335 `--metadata csl=FILE`.) If *FILE* is a URL, it will be
1336 fetched via HTTP. If *FILE* is not found relative to the
1337 working directory, it will be sought in the resource path
1338 and finally in the `csl` subdirectory of the
1339 pandoc user data directory.
1341`--citation-abbreviations=`*FILE*
1343: Set the `citation-abbreviations` field in the document's metadata to
1344 *FILE*, overriding any value set in the metadata. (This is equivalent to
1345 `--metadata citation-abbreviations=FILE`.)
1346 If *FILE* is a URL, it will be fetched via HTTP. If *FILE* is not
1347 found relative to the working directory, it will be sought
1348 in the resource path and finally in the `csl` subdirectory
1349 of the pandoc user data directory.
1351`--natbib`
1353: Use [`natbib`] for citations in LaTeX output. This option is not for use
1354 with the `--citeproc` option or with PDF output. It is intended for
1355 use in producing a LaTeX file that can be processed with [`bibtex`].
1357`--biblatex`
1359: Use [`biblatex`] for citations in LaTeX output. This option is not for use
1360 with the `--citeproc` option or with PDF output. It is intended for
1361 use in producing a LaTeX file that can be processed with [`bibtex`] or [`biber`].
1363## Math rendering in HTML {.options}
1365The default is to render TeX math as far as possible using Unicode characters.
1366Formulas are put inside a `span` with `class="math"`, so that they may be styled
1367differently from the surrounding text if needed. However, this gives acceptable
1368results only for basic math, usually you will want to use `--mathjax` or another
1369of the following options.
1371`--mathjax`[`=`*URL*]
1373: Use [MathJax] to display embedded TeX math in HTML output.
1374 TeX math will be put between `\(...\)` (for inline math)
1375 or `\[...\]` (for display math) and wrapped in `<span>` tags
1376 with class `math`. Then the MathJax JavaScript will render it.
1377 The *URL* should point to the `MathJax.js` load script.
1378 If a *URL* is not provided, a link to the Cloudflare CDN will
1379 be inserted.
1381`--mathml`
1383: Convert TeX math to [MathML] (in `epub3`, `docbook4`, `docbook5`, `jats`,
1384 `html4` and `html5`). This is the default in `odt` output. Note that
1385 currently only Firefox and Safari (and select e-book readers) natively
1386 support MathML.
1388`--webtex`[`=`*URL*]
1390: Convert TeX formulas to `<img>` tags that link to an external script
1391 that converts formulas to images. The formula will be URL-encoded
1392 and concatenated with the URL provided. For SVG images you can for
1393 example use `--webtex https://latex.codecogs.com/svg.latex?`.
1394 If no URL is specified, the CodeCogs URL generating PNGs
1395 will be used (`https://latex.codecogs.com/png.latex?`).
1396 Note: the `--webtex` option will affect Markdown output
1397 as well as HTML, which is useful if you're targeting a
1398 version of Markdown without native math support.
1400`--katex`[`=`*URL*]
1402: Use [KaTeX] to display embedded TeX math in HTML output.
1403 The *URL* is the base URL for the KaTeX library. That directory
1404 should contain a `katex.min.js` and a `katex.min.css` file.
1405 If a *URL* is not provided, a link to the KaTeX CDN will be inserted.
1407`--gladtex`
1409: Enclose TeX math in `<eq>` tags in HTML output. The resulting HTML
1410 can then be processed by [GladTeX] to produce images of the typeset
1411 formulas and an HTML file with links to these images.
1412 So, the procedure is:
1414 pandoc -s --gladtex input.md -o myfile.htex
1415 gladtex -d myfile-images myfile.htex
1416 # produces myfile.html and images in myfile-images
1418[MathML]: https://www.w3.org/Math/
1419[MathJax]: https://www.mathjax.org
1420[KaTeX]: https://github.com/Khan/KaTeX
1421[GladTeX]: https://humenda.github.io/GladTeX/
1423## Options for wrapper scripts {.options}
1425`--dump-args`
1427: Print information about command-line arguments to *stdout*, then exit.
1428 This option is intended primarily for use in wrapper scripts.
1429 The first line of output contains the name of the output file specified
1430 with the `-o` option, or `-` (for *stdout*) if no output file was
1431 specified. The remaining lines contain the command-line arguments,
1432 one per line, in the order they appear. These do not include regular
1433 pandoc options and their arguments, but do include any options appearing
1434 after a `--` separator at the end of the line.
1436`--ignore-args`
1438: Ignore command-line arguments (for use in wrapper scripts).
1439 Regular pandoc options are not ignored. Thus, for example,
1441 pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
1443 is equivalent to
1445 pandoc -o foo.html -s
1447# Exit codes
1449If pandoc completes successfully, it will return exit code 0.
1450Nonzero exit codes have the following meanings:
1452 Code Error
1453----- ------------------------------------
1454 3 PandocFailOnWarningError
1455 4 PandocAppError
1456 5 PandocTemplateError
1457 6 PandocOptionError
1458 21 PandocUnknownReaderError
1459 22 PandocUnknownWriterError
1460 23 PandocUnsupportedExtensionError
1461 24 PandocCiteprocError
1462 31 PandocEpubSubdirectoryError
1463 43 PandocPDFError
1464 47 PandocPDFProgramNotFoundError
1465 61 PandocHttpError
1466 62 PandocShouldNeverHappenError
1467 63 PandocSomeError
1468 64 PandocParseError
1469 65 PandocParsecError
1470 66 PandocMakePDFError
1471 67 PandocSyntaxMapError
1472 83 PandocFilterError
1473 91 PandocMacroLoop
1474 92 PandocUTF8DecodingError
1475 93 PandocIpynbDecodingError
1476 97 PandocCouldNotFindDataFileError
1477 99 PandocResourceNotFound
1478----- ------------------------------------
1480# Default files
1482The `--defaults` option may be used to specify a package
1483of options. Here is a sample defaults file demonstrating all of
1484the fields that may be used:
1486``` yaml
1487from: markdown+emoji
1488# reader: may be used instead of from:
1489to: html5
1490# writer: may be used instead of to:
1492# leave blank for output to stdout:
1493output-file:
1494# leave blank for input from stdin, use [] for no input:
1495input-files:
1496- preface.md
1497- content.md
1498# or you may use input-file: with a single value
1500template: letter
1501standalone: true
1502self-contained: false
1504# note that structured variables may be specified:
1505variables:
1506 documentclass: book
1507 classoption:
1508 - twosides
1509 - draft
1511# metadata values specified here are parsed as literal
1512# string text, not markdown:
1513metadata:
1514 author:
1515 - Sam Smith
1516 - Julie Liu
1517metadata-files:
1518- boilerplate.yaml
1519# or you may use metadata-file: with a single value
1521# Note that these take files, not their contents:
1522include-before-body: []
1523include-after-body: []
1524include-in-header: []
1525resource-path: ["."]
1527# turn on built-in citation processing. Note that if you need
1528# control over when the citeproc processing is done relative
1529# to other filters, you should instead use `citeproc` in the
1530# list of `filters` (see below).
1531citeproc: true
1532csl: ieee
1533bibliography:
1534- foobar.bib
1535- barbaz.json
1537# Filters will be assumed to be Lua filters if they have
1538# the .lua extension, and json filters otherwise. But
1539# the filter type can also be specified explicitly, as shown.
1540# Filters are run in the order specified.
1541# To include the built-in citeproc filter, use either `citeproc`
1542# or `{type: citeproc}`.
1543filters:
1544- wordcount.lua
1545- type: json
1546 path: foo.lua
1548file-scope: false
1550data-dir:
1552# ERROR, WARNING, or INFO
1553verbosity: INFO
1554log-file: log.json
1556# citeproc, natbib, or biblatex
1557cite-method: citeproc
1558# part, chapter, section, or default:
1559top-level-division: chapter
1560abbreviations:
1562pdf-engine: pdflatex
1563pdf-engine-opts:
1564- "-shell-escape"
1565# you may also use pdf-engine-opt: with a single option
1566# pdf-engine-opt: "-shell-escape"
1568# auto, preserve, or none
1569wrap: auto
1570columns: 78
1571dpi: 72
1573extract-media: mediadir
1575table-of-contents: true
1576toc-depth: 2
1577number-sections: false
1578# a list of offsets at each heading level
1579number-offset: [0,0,0,0,0,0]
1580# toc: may also be used instead of table-of-contents:
1581shift-heading-level-by: 1
1582section-divs: true
1583identifier-prefix: foo
1584title-prefix: ""
1585strip-empty-paragraphs: true
1586# lf, crlf, or native
1587eol: lf
1588strip-comments: false
1589indented-code-classes: []
1590ascii: true
1591default-image-extension: ".jpg"
1593# either a style name of a style definition file:
1594highlight-style: pygments
1595syntax-definitions:
1596- c.xml
1597# or you may use syntax-definition: with a single value
1598listings: false
1600reference-doc: myref.docx
1602# method is plain, webtex, gladtex, mathml, mathjax, katex
1603# you may specify a url with webtex, mathjax, katex
1604html-math-method:
1605 method: mathjax
1606 url: "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
1607# none, references, or javascript
1608email-obfuscation: javascript
1610tab-stop: 8
1611preserve-tabs: true
1613incremental: false
1614slide-level: 2
1616epub-subdirectory: EPUB
1617epub-metadata: meta.xml
1618epub-fonts:
1619- foobar.otf
1620epub-chapter-level: 1
1621epub-cover-image: cover.jpg
1623reference-links: true
1624# block, section, or document
1625reference-location: block
1626atx-headers: false
1628# accept, reject, or all
1629track-changes: accept
1631html-q-tags: false
1632css:
1633- site.css
1635# none, all, or best
1636ipynb-output: best
1638# A list of two-element lists
1639request-headers:
1640- ["User-Agent", "Mozilla/5.0"]
1642fail-if-warnings: false
1643dump-args: false
1644ignore-args: false
1645trace: false
1646```
1648Fields that are omitted will just have their regular
1649default values. So a defaults file can be as simple as
1650one line:
1652``` yaml
1653verbosity: INFO
1654```
1656Default files can be placed in the `defaults` subdirectory of
1657the user data directory and used from any directory. For
1658example, one could create a file specifying defaults for writing
1659letters, save it as `letter.yaml` in the `defaults` subdirectory
1660of the user data directory, and then invoke these defaults
1661from any directory using `pandoc --defaults letter`
1662or `pandoc -dletter`.
1664When multiple defaults are used, their contents will be combined.
1666Note that, where command-line arguments may be repeated
1667(`--metadata-file`, `--css`, `--include-in-header`,
1668`--include-before-body`, `--include-after-body`, `--variable`,
1669`--metadata`, `--syntax-definition`), the values specified on
1670the command line will combine with values specified in the
1671defaults file, rather than replacing them.
1673# Templates
1675When the `-s/--standalone` option is used, pandoc uses a template to
1676add header and footer material that is needed for a self-standing
1677document. To see the default template that is used, just type
1679 pandoc -D *FORMAT*
1681where *FORMAT* is the name of the output format. A custom template
1682can be specified using the `--template` option. You can also override
1683the system default templates for a given output format *FORMAT*
1684by putting a file `templates/default.*FORMAT*` in the user data
1685directory (see `--data-dir`, above). *Exceptions:*
1687- For `odt` output, customize the `default.opendocument`
1688 template.
1689- For `pdf` output, customize the `default.latex` template
1690 (or the `default.context` template, if you use `-t context`,
1691 or the `default.ms` template, if you use `-t ms`, or the
1692 `default.html` template, if you use `-t html`).
1693- `docx` and `pptx` have no template (however, you can use
1694 `--reference-doc` to customize the output).
1696Templates contain *variables*, which allow for the inclusion of
1697arbitrary information at any point in the file. They may be set at the
1698command line using the `-V/--variable` option. If a variable is not set,
1699pandoc will look for the key in the document's metadata, which can be set
1700using either [YAML metadata blocks][Extension: `yaml_metadata_block`]
1701or with the `-M/--metadata` option. In addition, some variables
1702are given default values by pandoc. See [Variables] below for
1703a list of variables used in pandoc's default templates.
1705If you use custom templates, you may need to revise them as pandoc
1706changes. We recommend tracking the changes in the default templates,
1707and modifying your custom templates accordingly. An easy way to do this
1708is to fork the [pandoc-templates] repository and merge in
1709changes after each pandoc release.
1711 [pandoc-templates]: https://github.com/jgm/pandoc-templates
1713## Template syntax
1715### Comments
1717Anything between the sequence `$--` and the end of the
1718line will be treated as a comment and omitted from the output.
1720### Delimiters
1722To mark variables and control structures in the template,
1723either `$`...`$` or `${`...`}` may be used as delimiters.
1724The styles may also be mixed in the same template, but the
1725opening and closing delimiter must match in each case. The
1726opening delimiter may be followed by one or more spaces
1727or tabs, which will be ignored. The closing delimiter may
1728be followed by one or more spaces or tabs, which will be
1729ignored.
1731To include a literal `$` in the document, use `$$`.
1733### Interpolated variables
1735A slot for an interpolated variable is a variable name surrounded
1736by matched delimiters. Variable names must begin with a letter
1737and can contain letters, numbers, `_`, `-`, and `.`. The
1738keywords `it`, `if`, `else`, `endif`, `for`, `sep`, and `endfor` may
1739not be used as variable names. Examples:
1741```
1742$foo$
1743$foo.bar.baz$
1744$foo_bar.baz-bim$
1745$ foo $
1746${foo}
1747${foo.bar.baz}
1748${foo_bar.baz-bim}
1749${ foo }
1750```
1752Variable names with periods are used to get at structured
1753variable values. So, for example, `employee.salary` will return the
1754value of the `salary` field of the object that is the value of
1755the `employee` field.
1757- If the value of the variable is simple value, it will be
1758 rendered verbatim. (Note that no escaping is done;
1759 the assumption is that the calling program will escape
1760 the strings appropriately for the output format.)
1761- If the value is a list, the values will be concatenated.
1762- If the value is a map, the string `true` will be rendered.
1763- Every other value will be rendered as the empty string.
1765### Conditionals
1767A conditional begins with `if(variable)` (enclosed in
1768matched delimiters) and ends with `endif` (enclosed in matched
1769delimiters). It may optionally contain an `else` (enclosed in
1770matched delimiters). The `if` section is used if
1771`variable` has a non-empty value, otherwise the `else`
1772section is used (if present). Examples:
1774```
1775$if(foo)$bar$endif$
1777$if(foo)$
1778 $foo$
1779$endif$
1781$if(foo)$
1782part one
1783$else$
1784part two
1785$endif$
1787${if(foo)}bar${endif}
1789${if(foo)}
1790 ${foo}
1791${endif}
1793${if(foo)}
1794${ foo.bar }
1795${else}
1796no foo!
1797${endif}
1798```
1800The keyword `elseif` may be used to simplify complex nested
1801conditionals:
1803```
1804$if(foo)$
1805XXX
1806$elseif(bar)$
1807YYY
1808$else$
1809ZZZ
1810$endif$
1811```
1813### For loops
1815A for loop begins with `for(variable)` (enclosed in
1816matched delimiters) and ends with `endfor` (enclosed in matched
1817delimiters.
1819- If `variable` is an array, the material inside the loop will
1820 be evaluated repeatedly, with `variable` being set to each
1821 value of the array in turn, and concatenated.
1822- If `variable` is a map, the material inside will be set to
1823 the map.
1824- If the value of the associated variable is not an array or
1825 a map, a single iteration will be performed on its value.
1827Examples:
1829```
1830$for(foo)$$foo$$sep$, $endfor$
1832$for(foo)$
1833 - $foo.last$, $foo.first$
1834$endfor$
1836${ for(foo.bar) }
1837 - ${ foo.bar.last }, ${ foo.bar.first }
1838${ endfor }
1840$for(mymap)$
1841$it.name$: $it.office$
1842$endfor$
1843```
1845You may optionally specify a separator between consecutive
1846values using `sep` (enclosed in matched delimiters). The
1847material between `sep` and the `endfor` is the separator.
1849```
1850${ for(foo) }${ foo }${ sep }, ${ endfor }
1851```
1853Instead of using `variable` inside the loop, the special
1854anaphoric keyword `it` may be used.
1856```
1857${ for(foo.bar) }
1858 - ${ it.last }, ${ it.first }
1859${ endfor }
1860```
1862### Partials
1864Partials (subtemplates stored in different files) may be
1865included by using the name of the partial, followed
1866by `()`, for example:
1868```
1869${ styles() }
1870```
1872Partials will be sought in the directory containing
1873the main template. The file name will be assumed to
1874have the same extension as the main template if it
1875lacks an extension. When calling the partial, the
1876full name including file extension can also be used:
1878```
1879${ styles.html() }
1880```
1882(If a partial is not found in the directory of the
1883template, it will also be sought in the `templates`
1884subdirectory of the user data directory.)
1886Partials may optionally be applied to variables using
1887a colon:
1889```
1890${ date:fancy() }
1892${ articles:bibentry() }
1893```
1895If `articles` is an array, this will iterate over its
1896values, applying the partial `bibentry()` to each one. So the
1897second example above is equivalent to
1899```
1900${ for(articles) }
1901${ it:bibentry() }
1902${ endfor }
1903```
1905Note that the anaphoric keyword `it` must be used when
1906iterating over partials. In the above examples,
1907the `bibentry` partial should contain `it.title`
1908(and so on) instead of `articles.title`.
1910Final newlines are omitted from included partials.
1912Partials may include other partials.
1914A separator between values of an array may be specified
1915in square brackets, immediately after the variable name
1916or partial:
1918```
1919${months[, ]}$
1921${articles:bibentry()[; ]$
1922```
1924The separator in this case is literal and (unlike with `sep`
1925in an explicit `for` loop) cannot contain interpolated
1926variables or other template directives.
1928### Nesting
1930To ensure that content is "nested," that is, subsequent lines
1931indented, use the `^` directive:
1933```
1934$item.number$ $^$$item.description$ ($item.price$)
1935```
1937In this example, if `item.description` has multiple lines,
1938they will all be indented to line up with the first line:
1940```
194100123 A fine bottle of 18-year old
1942 Oban whiskey. ($148)
1943```
1945To nest multiple lines to the same level, align them
1946with the `^` directive in the template. For example:
1948```
1949$item.number$ $^$$item.description$ ($item.price$)
1950 (Available til $item.sellby$.)
1951```
1953will produce
1955```
195600123 A fine bottle of 18-year old
1957 Oban whiskey. ($148)
1958 (Available til March 30, 2020.)
1959```
1961If a variable occurs by itself on a line, preceded by whitespace
1962and not followed by further text or directives on the same line,
1963and the variable's value contains multiple lines, it will be
1964nested automatically.
1966### Breakable spaces
1968Normally, spaces in the template itself (as opposed to values of
1969the interpolated variables) are not breakable, but they can be
1970made breakable in part of the template by using the `~` keyword
1971(ended with another `~`).
1973```
1974$~$This long line may break if the document is rendered
1975with a short line length.$~$
1976```
1978### Pipes
1980A pipe transforms the value of a variable or partial. Pipes are
1981specified using a slash (`/`) between the variable name (or partial)
1982and the pipe name. Example:
1984```
1985$for(name)$
1986$name/uppercase$
1987$endfor$
1989$for(metadata/pairs)$
1990- $it.key$: $it.value$
1991$endfor$
1993$employee:name()/uppercase$
1994```
1996Pipes may be chained:
1998```
1999$for(employees/pairs)$
2000$it.key/alpha/uppercase$. $it.name$
2001$endfor$
2002```
2004Some pipes take parameters:
2006```
2007|----------------------|------------|
2008$for(employee)$
2009$it.name.first/uppercase/left 20 "| "$$it.name.salary/right 10 " | " " |"$
2010$endfor$
2011|----------------------|------------|
2012```
2014Currently the following pipes are predefined:
2016- `pairs`: Converts a map or array to an array of maps,
2017 each with `key` and `value` fields. If the original
2018 value was an array, the `key` will be the array index,
2019 starting with 1.
2021- `uppercase`: Converts text to uppercase.
2023- `lowercase`: Converts text to lowercase.
2025- `length`: Returns the length of the value: number
2026 of characters for a textual value, number of elements
2027 for a map or array.
2029- `reverse`: Reverses a textual value or array,
2030 and has no effect on other values.
2032- `first`: Returns the first value of an array, if
2033 applied to a non-empty array; otherwise returns
2034 the original value.
2036- `last`: Returns the last value of an array, if
2037 applied to a non-empty array; otherwise returns
2038 the original value.
2040- `rest`: Returns all but the first value of an array, if
2041 applied to a non-empty array; otherwise returns
2042 the original value.
2044- `allbutlast`: Returns all but the last value of an array, if
2045 applied to a non-empty array; otherwise returns
2046 the original value.
2048- `chomp`: Removes trailing newlines (and breakable space).
2050- `nowrap`: Disables line wrapping on breakable spaces.
2052- `alpha`: Converts textual values that can be
2053 read as an integer into lowercase alphabetic
2054 characters `a..z` (mod 26). This can be used to get lettered
2055 enumeration from array indices. To get uppercase
2056 letters, chain with `uppercase`.
2058- `roman`: Converts textual values that can be
2059 read as an integer into lowercase roman numerials.
2060 This can be used to get lettered enumeration from array indices.
2061 To get uppercase roman, chain with `uppercase`.
2063- `left n "leftborder" "rightborder"`: Renders a textual value
2064 in a block of width `n`, aligned to the left, with an optional
2065 left and right border. Has no effect on other values. This
2066 can be used to align material in tables. Widths are positive
2067 integers indicating the number of characters. Borders
2068 are strings inside double quotes; literal `"` and `\` characters
2069 must be backslash-escaped.
2071- `right n "leftborder" "rightborder"`: Renders a textual value
2072 in a block of width `n`, aligned to the right, and has no
2073 effect on other values.
2075- `center n "leftborder" "rightborder"`: Renders a textual
2076 value in a block of width `n`, aligned to the center, and has
2077 no effect on other values.
2080## Variables
2082### Metadata variables
2084`title`, `author`, `date`
2085: allow identification of basic aspects of the document. Included
2086 in PDF metadata through LaTeX and ConTeXt. These can be set
2087 through a [pandoc title block][Extension: `pandoc_title_block`],
2088 which allows for multiple authors, or through a
2089 [YAML metadata block][Extension: `yaml_metadata_block`]:
2091 ---
2092 author:
2093 - Aristotle
2094 - Peter Abelard
2095 ...
2097 Note that if you just want to set PDF or HTML metadata, without
2098 including a title block in the document itself, you can
2099 set the `title-meta`, `author-meta`, and `date-meta`
2100 variables. (By default these are set automatically, based
2101 on `title`, `author`, and `date`.)
2103`subtitle`
2104: document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and docx
2105 documents
2107`abstract`
2108: document summary, included in LaTeX, ConTeXt, AsciiDoc, and docx
2109 documents
2111`keywords`
2112: list of keywords to be included in HTML, PDF, ODT, pptx, docx
2113 and AsciiDoc metadata; repeat as for `author`, above
2115`subject`
2116: document subject, included in ODT, PDF, docx and pptx metadata
2118`description`
2119: document description, included in ODT, docx and pptx metadata. Some
2120 applications show this as `Comments` metadata.
2122`category`
2123: document category, included in docx and pptx metadata
2125Additionally,
2126any root-level string metadata, not included in ODT, docx
2127or pptx metadata is added as a *custom property*.
2128The following [YAML] metadata block for instance:
2130 ---
2131 title: 'This is the title'
2132 subtitle: "This is the subtitle"
2133 author:
2134 - Author One
2135 - Author Two
2136 description: |
2137 This is a long
2138 description.
2140 It consists of two paragraphs
2141 ...
2143will include `title`, `author` and `description` as standard document
2144properties and `subtitle` as a custom property when converting to docx,
2145ODT or pptx.
2147### Language variables
2149`lang`
2150: identifies the main language of the document using IETF language
2151 tags (following the [BCP 47] standard), such as `en` or `en-GB`.
2152 The [Language subtag lookup] tool can look up or verify these tags.
2153 This affects most formats, and controls hyphenation in PDF output
2154 when using LaTeX (through [`babel`] and [`polyglossia`]) or ConTeXt.
2156 Use native pandoc [Divs and Spans] with the `lang` attribute to
2157 switch the language:
2159 ---
2160 lang: en-GB
2161 ...
2163 Text in the main document language (British English).
2165 ::: {lang=fr-CA}
2166 > Cette citation est écrite en français canadien.
2167 :::
2169 More text in English. ['Zitat auf Deutsch.']{lang=de}
2171`dir`
2172: the base script direction, either `rtl` (right-to-left)
2173 or `ltr` (left-to-right).
2175 For bidirectional documents, native pandoc `span`s and `div`s
2176 with the `dir` attribute (value `rtl` or `ltr`) can be used to
2177 override the base direction in some output formats.
2178 This may not always be necessary if the final renderer
2179 (e.g. the browser, when generating HTML) supports the
2180 [Unicode Bidirectional Algorithm].
2182 When using LaTeX for bidirectional documents, only the `xelatex` engine
2183 is fully supported (use `--pdf-engine=xelatex`).
2185[BCP 47]: https://tools.ietf.org/html/bcp47
2186[Unicode Bidirectional Algorithm]: https://www.w3.org/International/articles/inline-bidi-markup/uba-basics
2187[Language subtag lookup]: https://r12a.github.io/app-subtags/
2189### Variables for HTML
2191`document-css`
2192: Enables inclusion of most of the CSS in the `styles.html`
2193 [partial](#partials) (have a look with
2194 `pandoc --print-default-data-file=templates/styles.html`).
2195 Unless you use [`--css`](#option--css), this variable
2196 is set to `true` by default. You can disable it with
2197 e.g. `pandoc -M document-css=false`.
2199`mainfont`
2200: sets the CSS `font-family` property on the `html` element.
2202`fontsize`
2203: sets the base CSS `font-size`, which you'd usually set
2204 to e.g. `20px`, but it also accepts `pt`
2205 (12pt = 16px in most browsers).
2207`fontcolor`
2208: sets the CSS `color` property on the `html` element.
2210`linkcolor`
2211: sets the CSS `color` property on all links.
2213`monofont`
2214: sets the CSS `font-family` property on `code` elements.
2216`linestretch`
2217: sets the CSS `line-height` property on the `html` element,
2218 which is preferred to be unitless.
2220`backgroundcolor`
2221: sets the CSS `background-color` property on the `html` element.
2223`margin-left`, `margin-right`, `margin-top`, `margin-bottom`
2224: sets the corresponding CSS `padding` properties on the `body` element.
2226### Variables for HTML math
2228`classoption`
2229: when using [KaTeX](#option--katex), you can render display math equations
2230 flush left using [YAML metadata](#layout) or with `-M classoption=fleqn`.
2232### Variables for HTML slides
2234These affect HTML output when [producing slide shows with pandoc].
2236All [reveal.js configuration options] are available as variables.
2237To turn off boolean flags that default to true in reveal.js, use `0`.
2239`revealjs-url`
2240: base URL for reveal.js documents (defaults to
2241 `https://unpkg.com/reveal.js@^4/`)
2243`s5-url`
2244: base URL for S5 documents (defaults to `s5/default`)
2246`slidy-url`
2247: base URL for Slidy documents (defaults to
2248 `https://www.w3.org/Talks/Tools/Slidy2`)
2250`slideous-url`
2251: base URL for Slideous documents (defaults to `slideous`)
2253`title-slide-attributes`
2254: additional attributes for the title slide of reveal.js slide shows.
2255 See [background in reveal.js and beamer] for an example.
2257[reveal.js configuration options]: https://revealjs.com/config/
2259### Variables for Beamer slides
2261These variables change the appearance of PDF slides using [`beamer`].
2263`aspectratio`
2264: slide aspect ratio (`43` for 4:3 [default], `169` for 16:9,
2265 `1610` for 16:10, `149` for 14:9, `141` for 1.41:1, `54` for 5:4,
2266 `32` for 3:2)
2268`beamerarticle`
2269: produce an article from Beamer slides
2271`beameroption`
2272: add extra beamer option with `\setbeameroption{}`
2274`institute`
2275: author affiliations: can be a list when there are multiple authors
2277`logo`
2278: logo image for slides
2280`navigation`
2281: controls navigation symbols (default is `empty` for no navigation
2282 symbols; other valid values are `frame`, `vertical`, and `horizontal`)
2284`section-titles`
2285: enables "title pages" for new sections (default is true)
2287`theme`, `colortheme`, `fonttheme`, `innertheme`, `outertheme`
2288: beamer themes
2290`themeoptions`
2291: options for LaTeX beamer themes (a list).
2293`titlegraphic`
2294: image for title slide
2296### Variables for PowerPoint
2298These variables control the visual aspects of a slide show that
2299are not easily controlled via templates.
2301`monofont`
2302: font to use for code.
2304### Variables for LaTeX
2306Pandoc uses these variables when [creating a PDF] with a LaTeX engine.
2308#### Layout
2310`block-headings`
2311: make `\paragraph` and `\subparagraph` (fourth- and
2312 fifth-level headings, or fifth- and sixth-level with book
2313 classes) free-standing rather than run-in; requires further
2314 formatting to distinguish from `\subsubsection` (third- or
2315 fourth-level headings). Instead of using this option,
2316 [KOMA-Script] can adjust headings more extensively:
2318 ---
2319 documentclass: scrartcl
2320 header-includes: |
2321 \RedeclareSectionCommand[
2322 beforeskip=-10pt plus -2pt minus -1pt,
2323 afterskip=1sp plus -1sp minus 1sp,
2324 font=\normalfont\itshape]{paragraph}
2325 \RedeclareSectionCommand[
2326 beforeskip=-10pt plus -2pt minus -1pt,
2327 afterskip=1sp plus -1sp minus 1sp,
2328 font=\normalfont\scshape,
2329 indent=0pt]{subparagraph}
2330 ...
2332`classoption`
2333: option for document class, e.g. `oneside`; repeat for multiple options:
2335 ---
2336 classoption:
2337 - twocolumn
2338 - landscape
2339 ...
2341`documentclass`
2342: document class: usually one of the standard classes, [`article`], [`book`],
2343 and [`report`]; the [KOMA-Script] equivalents, `scrartcl`, `scrbook`,
2344 and `scrreprt`, which default to smaller margins; or [`memoir`]
2346`geometry`
2347: option for [`geometry`] package, e.g. `margin=1in`;
2348 repeat for multiple options:
2350 ---
2351 geometry:
2352 - top=30mm
2353 - left=20mm
2354 - heightrounded
2355 ...
2357`hyperrefoptions`
2358: option for [`hyperref`] package, e.g. `linktoc=all`;
2359 repeat for multiple options:
2361 ---
2362 hyperrefoptions:
2363 - linktoc=all
2364 - pdfwindowui
2365 - pdfpagemode=FullScreen
2366 ...
2368`indent`
2369: if true, pandoc will use document class settings for indentation (the default LaTeX template
2370 otherwise removes indentation and adds space between paragraphs)
2372`linestretch`
2373: adjusts line spacing using the [`setspace`]
2374 package, e.g. `1.25`, `1.5`
2376`margin-left`, `margin-right`, `margin-top`, `margin-bottom`
2377: sets margins if `geometry` is not used (otherwise `geometry`
2378 overrides these)
2380`pagestyle`
2381: control `\pagestyle{}`: the default article class
2382 supports `plain` (default), `empty` (no running heads or page numbers),
2383 and `headings` (section titles in running heads)
2385`papersize`
2386: paper size, e.g. `letter`, `a4`
2388`secnumdepth`
2389: numbering depth for sections (with `--number-sections` option
2390 or `numbersections` variable)
2392#### Fonts
2394`fontenc`
2395: allows font encoding to be specified through `fontenc` package (with `pdflatex`);
2396 default is `T1` (see [LaTeX font encodings guide])
2398`fontfamily`
2399: font package for use with `pdflatex`:
2400 [TeX Live] includes many options, documented in the [LaTeX Font Catalogue].
2401 The default is [Latin Modern][`lm`].
2403`fontfamilyoptions`
2404: options for package used as `fontfamily`; repeat for multiple options.
2405 For example, to use the Libertine font with proportional lowercase
2406 (old-style) figures through the [`libertinus`] package:
2408 ---
2409 fontfamily: libertinus
2410 fontfamilyoptions:
2411 - osf
2412 - p
2413 ...
2415`fontsize`
2416: font size for body text. The standard classes allow 10pt, 11pt, and
2417 12pt. To use another size, set `documentclass` to one of
2418 the [KOMA-Script] classes, such as `scrartcl` or `scrbook`.
2420`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`
2421: font families for use with `xelatex` or
2422 `lualatex`: take the name of any system font, using the
2423 [`fontspec`] package. `CJKmainfont` uses the [`xecjk`] package.
2425`mainfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions`
2426: options to use with `mainfont`, `sansfont`, `monofont`, `mathfont`,
2427 `CJKmainfont` in `xelatex` and `lualatex`. Allow for any
2428 choices available through [`fontspec`]; repeat for multiple
2429 options. For example, to use the [TeX Gyre] version of
2430 Palatino with lowercase figures:
2432 ---
2433 mainfont: TeX Gyre Pagella
2434 mainfontoptions:
2435 - Numbers=Lowercase
2436 - Numbers=Proportional
2437 ...
2439`microtypeoptions`
2440: options to pass to the microtype package
2442#### Links
2444`colorlinks`
2445: add color to link text; automatically enabled if any of
2446 `linkcolor`, `filecolor`, `citecolor`, `urlcolor`, or `toccolor` are set
2448`linkcolor`, `filecolor`, `citecolor`, `urlcolor`, `toccolor`
2449: color for internal links, external links, citation links, linked
2450 URLs, and links in table of contents, respectively: uses options
2451 allowed by [`xcolor`], including the `dvipsnames`, `svgnames`, and
2452 `x11names` lists
2454`links-as-notes`
2455: causes links to be printed as footnotes
2457#### Front matter
2459`lof`, `lot`
2460: include list of figures, list of tables
2462`thanks`
2463: contents of acknowledgments footnote after document title
2465`toc`
2466: include table of contents (can also be set using `--toc/--table-of-contents`)
2468`toc-depth`
2469: level of section to include in table of contents
2471#### BibLaTeX Bibliographies
2473These variables function when using BibLaTeX for [citation rendering].
2475`biblatexoptions`
2476: list of options for biblatex
2478`biblio-style`
2479: bibliography style, when used with `--natbib` and `--biblatex`.
2481`biblio-title`
2482: bibliography title, when used with `--natbib` and `--biblatex`.
2484`bibliography`
2485: bibliography to use for resolving references
2487`natbiboptions`
2488: list of options for natbib
2490[KOMA-Script]: https://ctan.org/pkg/koma-script
2491[LaTeX Font Catalogue]: https://tug.org/FontCatalogue/
2492[LaTeX font encodings guide]: https://ctan.org/pkg/encguide
2493[TeX Gyre]: http://www.gust.org.pl/projects/e-foundry/tex-gyre
2494[`article`]: https://ctan.org/pkg/article
2495[`book`]: https://ctan.org/pkg/book
2496[`libertinus`]: https://ctan.org/pkg/libertinus
2497[`memoir`]: https://ctan.org/pkg/memoir
2498[`report`]: https://ctan.org/pkg/report
2500### Variables for ConTeXt
2502Pandoc uses these variables when [creating a PDF] with ConTeXt.
2504`fontsize`
2505: font size for body text (e.g. `10pt`, `12pt`)
2507`headertext`, `footertext`
2508: text to be placed in running header or footer (see [ConTeXt Headers and Footers]);
2509 repeat up to four times for different placement
2511`indenting`
2512: controls indentation of paragraphs, e.g. `yes,small,next` (see [ConTeXt Indentation]);
2513 repeat for multiple options
2515`interlinespace`
2516: adjusts line spacing, e.g. `4ex` (using [`setupinterlinespace`]);
2517 repeat for multiple options
2519`layout`
2520: options for page margins and text arrangement (see [ConTeXt Layout]);
2521 repeat for multiple options
2523`linkcolor`, `contrastcolor`
2524: color for links outside and inside a page, e.g. `red`, `blue` (see [ConTeXt Color])
2526`linkstyle`
2527: typeface style for links, e.g. `normal`, `bold`, `slanted`, `boldslanted`, `type`, `cap`, `small`
2529`lof`, `lot`
2530: include list of figures, list of tables
2532`mainfont`, `sansfont`, `monofont`, `mathfont`
2533: font families: take the name of any system font (see [ConTeXt Font Switching])
2535`margin-left`, `margin-right`, `margin-top`, `margin-bottom`
2536: sets margins, if `layout` is not used (otherwise `layout`
2537 overrides these)
2539`pagenumbering`
2540: page number style and location (using [`setuppagenumbering`]);
2541 repeat for multiple options
2543`papersize`
2544: paper size, e.g. `letter`, `A4`, `landscape` (see [ConTeXt Paper Setup]);
2545 repeat for multiple options
2547`pdfa`
2548: adds to the preamble the setup necessary to generate PDF/A of the type
2549 specified, e.g. `1a:2005`, `2a`. If no type is specified (i.e. the value
2550 is set to True, by e.g. `--metadata=pdfa` or `pdfa: true` in a YAML metadata
2551 block), `1b:2005` will be used as default, for reasons of backwards
2552 compatibility. Using `--variable=pdfa` without specified value is not supported.
2553 To successfully generate PDF/A the required ICC color profiles have to
2554 be available and the content and all included files (such as images)
2555 have to be standard conforming. The ICC profiles and output intent
2556 may be specified using the variables `pdfaiccprofile` and `pdfaintent`.
2557 See also [ConTeXt PDFA] for more details.
2559`pdfaiccprofile`
2560: when used in conjunction with `pdfa`, specifies the ICC profile to use
2561 in the PDF, e.g. `default.cmyk`. If left unspecified, `sRGB.icc` is
2562 used as default. May be repeated to include multiple profiles. Note that
2563 the profiles have to be available on the system. They can be obtained
2564 from [ConTeXt ICC Profiles].
2566`pdfaintent`
2567: when used in conjunction with `pdfa`, specifies the output intent for
2568 the colors, e.g. `ISO coated v2 300\letterpercent\space (ECI)`
2569 If left unspecified, `sRGB IEC61966-2.1` is used as default.
2571`toc`
2572: include table of contents (can also be set using `--toc/--table-of-contents`)
2574`whitespace`
2575: spacing between paragraphs, e.g. `none`, `small` (using [`setupwhitespace`])
2577`includesource`
2578: include all source documents as file attachments in the PDF file
2580[ConTeXt Paper Setup]: https://wiki.contextgarden.net/PaperSetup
2581[ConTeXt Layout]: https://wiki.contextgarden.net/Layout
2582[ConTeXt Font Switching]: https://wiki.contextgarden.net/Font_Switching
2583[ConTeXt Color]: https://wiki.contextgarden.net/Color
2584[ConTeXt Headers and Footers]: https://wiki.contextgarden.net/Headers_and_Footers
2585[ConTeXt Indentation]: https://wiki.contextgarden.net/Indentation
2586[ConTeXt ICC Profiles]: https://wiki.contextgarden.net/PDFX#ICC_profiles
2587[ConTeXt PDFA]: https://wiki.contextgarden.net/PDF/A
2588[`setupwhitespace`]: https://wiki.contextgarden.net/Command/setupwhitespace
2589[`setupinterlinespace`]: https://wiki.contextgarden.net/Command/setupinterlinespace
2590[`setuppagenumbering`]: https://wiki.contextgarden.net/Command/setuppagenumbering
2592### Variables for `wkhtmltopdf`
2594Pandoc uses these variables when [creating a PDF] with [`wkhtmltopdf`].
2595The `--css` option also affects the output.
2597`footer-html`, `header-html`
2598: add information to the header and footer
2600`margin-left`, `margin-right`, `margin-top`, `margin-bottom`
2601: set the page margins
2603`papersize`
2604: sets the PDF paper size
2606### Variables for man pages
2608`adjusting`
2609: adjusts text to left (`l`), right (`r`), center (`c`),
2610 or both (`b`) margins
2612`footer`
2613: footer in man pages
2615`header`
2616: header in man pages
2618`hyphenate`
2619: if `true` (the default), hyphenation will be used
2621`section`
2622: section number in man pages
2624### Variables for ms
2626`fontfamily`
2627: font family (e.g. `T` or `P`)
2629`indent`
2630: paragraph indent (e.g. `2m`)
2632`lineheight`
2633: line height (e.g. `12p`)
2635`pointsize`
2636: point size (e.g. `10p`)
2638### Variables set automatically
2640Pandoc sets these variables automatically in response to [options] or
2641document contents; users can also modify them. These vary depending
2642on the output format, and include the following:
2644`body`
2645: body of document
2647`date-meta`
2648: the `date` variable converted to ISO 8601 YYYY-MM-DD,
2649 included in all HTML based formats (dzslides, epub,
2650 html, html4, html5, revealjs, s5, slideous, slidy).
2651 The recognized formats for `date` are: `mm/dd/yyyy`,
2652 `mm/dd/yy`, `yyyy-mm-dd` (ISO 8601), `dd MM yyyy`
2653 (e.g. either `02 Apr 2018` or `02 April 2018`),
2654 `MM dd, yyyy` (e.g. `Apr. 02, 2018` or `April 02, 2018),
2655 `yyyy[mm[dd]]]` (e.g. `20180402, `201804` or `2018`).
2657`header-includes`
2658: contents specified by `-H/--include-in-header` (may have multiple
2659 values)
2661`include-before`
2662: contents specified by `-B/--include-before-body` (may have
2663 multiple values)
2665`include-after`
2666: contents specified by `-A/--include-after-body` (may have
2667 multiple values)
2669`meta-json`
2670: JSON representation of all of the document's metadata. Field
2671 values are transformed to the selected output format.
2673`numbersections`
2674: non-null value if `-N/--number-sections` was specified
2676`sourcefile`, `outputfile`
2677: source and destination filenames, as given on the command line.
2678 `sourcefile` can also be a list if input comes from multiple files,
2679 or empty if input is from stdin. You can use the following snippet in
2680 your template to distinguish them:
2682 $if(sourcefile)$
2683 $for(sourcefile)$
2684 $sourcefile$
2685 $endfor$
2686 $else$
2687 (stdin)
2688 $endif$
2690 Similarly, `outputfile` can be `-` if output goes to the terminal.
2692 If you need absolute paths, use e.g. `$curdir$/$sourcefile$`.
2694`curdir`
2695: working directory from which pandoc is run.
2697`toc`
2698: non-null value if `--toc/--table-of-contents` was specified
2700`toc-title`
2701: title of table of contents (works only with EPUB,
2702 HTML, opendocument, odt, docx, pptx, beamer, LaTeX)
2704[pandoc-templates]: https://github.com/jgm/pandoc-templates
2706# Extensions
2708The behavior of some of the readers and writers can be adjusted by
2709enabling or disabling various extensions.
2711An extension can be enabled by adding `+EXTENSION`
2712to the format name and disabled by adding `-EXTENSION`. For example,
2713`--from markdown_strict+footnotes` is strict Markdown with footnotes
2714enabled, while `--from markdown-footnotes-pipe_tables` is pandoc's
2715Markdown without footnotes or pipe tables.
2717The markdown reader and writer make by far the most use of extensions.
2718Extensions only used by them are therefore covered in the
2719section [Pandoc's Markdown] below (See [Markdown variants] for
2720`commonmark` and `gfm`.) In the following, extensions that also work
2721for other formats are covered.
2723Note that markdown extensions added to the `ipynb` format
2724affect Markdown cells in Jupyter notebooks (as do command-line
2725options like `--atx-headers`).
2727## Typography
2729#### Extension: `smart` ####
2731Interpret straight quotes as curly quotes, `---` as em-dashes,
2732`--` as en-dashes, and `...` as ellipses. Nonbreaking spaces are
2733inserted after certain abbreviations, such as "Mr."
2735This extension can be enabled/disabled for the following formats:
2737input formats
2738: `markdown`, `commonmark`, `latex`, `mediawiki`, `org`, `rst`, `twiki`
2740output formats
2741: `markdown`, `latex`, `context`, `rst`
2743enabled by default in
2744: `markdown`, `latex`, `context` (both input and output)
2746Note: If you are *writing* Markdown, then the `smart` extension
2747has the reverse effect: what would have been curly quotes comes
2748out straight.
2750In LaTeX, `smart` means to use the standard TeX ligatures
2751for quotation marks (` `` ` and ` '' ` for double quotes,
2752`` ` `` and `` ' `` for single quotes) and dashes (`--` for
2753en-dash and `---` for em-dash). If `smart` is disabled,
2754then in reading LaTeX pandoc will parse these characters
2755literally. In writing LaTeX, enabling `smart` tells pandoc
2756to use the ligatures when possible; if `smart` is disabled
2757pandoc will use unicode quotation mark and dash characters.
2759## Headings and sections
2761#### Extension: `auto_identifiers` ####
2763A heading without an explicitly specified identifier will be
2764automatically assigned a unique identifier based on the heading text.
2766This extension can be enabled/disabled for the following formats:
2768input formats
2769: `markdown`, `latex`, `rst`, `mediawiki`, `textile`
2771output formats
2772: `markdown`, `muse`
2774enabled by default in
2775: `markdown`, `muse`
2777The default algorithm used to derive the identifier from the
2778heading text is:
2780 - Remove all formatting, links, etc.
2781 - Remove all footnotes.
2782 - Remove all non-alphanumeric characters,
2783 except underscores, hyphens, and periods.
2784 - Replace all spaces and newlines with hyphens.
2785 - Convert all alphabetic characters to lowercase.
2786 - Remove everything up to the first letter (identifiers may
2787 not begin with a number or punctuation mark).
2788 - If nothing is left after this, use the identifier `section`.
2790Thus, for example,
2792 Heading Identifier
2793 ------------------------------- ----------------------------
2794 `Heading identifiers in HTML` `heading-identifiers-in-html`
2795 `Maître d'hôtel` `maître-dhôtel`
2796 `*Dogs*?--in *my* house?` `dogs--in-my-house`
2797 `[HTML], [S5], or [RTF]?` `html-s5-or-rtf`
2798 `3. Applications` `applications`
2799 `33` `section`
2801These rules should, in most cases, allow one to determine the identifier
2802from the heading text. The exception is when several headings have the
2803same text; in this case, the first will get an identifier as described
2804above; the second will get the same identifier with `-1` appended; the
2805third with `-2`; and so on.
2807(However, a different algorithm is used if
2808`gfm_auto_identifiers` is enabled; see below.)
2810These identifiers are used to provide link targets in the table of
2811contents generated by the `--toc|--table-of-contents` option. They
2812also make it easy to provide links from one section of a document to
2813another. A link to this section, for example, might look like this:
2815 See the section on
2816 [heading identifiers](#heading-identifiers-in-html-latex-and-context).
2818Note, however, that this method of providing links to sections works
2819only in HTML, LaTeX, and ConTeXt formats.
2821If the `--section-divs` option is specified, then each section will
2822be wrapped in a `section` (or a `div`, if `html4` was specified),
2823and the identifier will be attached to the enclosing `<section>`
2824(or `<div>`) tag rather than the heading itself. This allows entire
2825sections to be manipulated using JavaScript or treated differently in
2826CSS.
2828#### Extension: `ascii_identifiers` ####
2830Causes the identifiers produced by `auto_identifiers` to be pure ASCII.
2831Accents are stripped off of accented Latin letters, and non-Latin
2832letters are omitted.
2834#### Extension: `gfm_auto_identifiers` ####
2836Changes the algorithm used by `auto_identifiers` to conform to
2837GitHub's method. Spaces are converted to dashes (`-`),
2838uppercase characters to lowercase characters, and punctuation
2839characters other than `-` and `_` are removed.
2840Emojis are replaced by their names.
2842## Math Input
2844The extensions [`tex_math_dollars`](#extension-tex_math_dollars),
2845[`tex_math_single_backslash`](#extension-tex_math_single_backslash), and
2846[`tex_math_double_backslash`](#extension-tex_math_double_backslash)
2847are described in the section about Pandoc's Markdown.
2849However, they can also be used with HTML input. This is handy for
2850reading web pages formatted using MathJax, for example.
2852## Raw HTML/TeX
2854The following extensions are described in more detail in
2855their respective sections of [Pandoc's Markdown]:
2857- [`raw_html`](#extension-raw_html) allows HTML elements which
2858 are not representable in pandoc's AST to be parsed as raw HTML.
2859 By default, this is disabled for HTML input.
2861- [`raw_tex`](#extension-raw_tex) allows raw LaTeX, TeX, and ConTeXt
2862 to be included in a document. This extension can be enabled/disabled
2863 for the following formats (in addition to `markdown`):
2865 input formats
2866 : `latex`, `textile`, `html` (environments, `\ref`, and
2867 `\eqref` only), `ipynb`
2869 output formats
2870 : `textile`, `commonmark`
2872 Note: as applied to `ipynb`, `raw_html` and `raw_tex` affect not
2873 only raw TeX in markdown cells, but data with mime type
2874 `text/html` in output cells. Since the `ipynb` reader attempts
2875 to preserve the richest possible outputs when several options
2876 are given, you will get best results if you disable `raw_html`
2877 and `raw_tex` when converting to formats like `docx` which don't
2878 allow raw `html` or `tex`.
2880- [`native_divs`](#extension-native_divs) causes HTML `div`
2881 elements to be parsed as native pandoc Div blocks.
2882 If you want them to be parsed as raw HTML, use
2883 `-f html-native_divs+raw_html`.
2885- [`native_spans`](#extension-native_spans) causes HTML `span`
2886 elements to be parsed as native pandoc Span inlines.
2887 If you want them to be parsed as raw HTML, use
2888 `-f html-native_spans+raw_html`. If you want to drop all
2889 `div`s and `span`s when converting HTML to Markdown, you
2890 can use `pandoc -f html-native_divs-native_spans -t markdown`.
2892## Literate Haskell support
2894#### Extension: `literate_haskell` ####
2896Treat the document as literate Haskell source.
2898This extension can be enabled/disabled for the following formats:
2900input formats
2901: `markdown`, `rst`, `latex`
2903output formats
2904: `markdown`, `rst`, `latex`, `html`
2906If you append `+lhs` (or `+literate_haskell`) to one of the formats
2907above, pandoc will treat the document as literate Haskell source.
2908This means that
2910 - In Markdown input, "bird track" sections will be parsed as Haskell
2911 code rather than block quotations. Text between `\begin{code}`
2912 and `\end{code}` will also be treated as Haskell code. For
2913 ATX-style headings the character '=' will be used instead of '#'.
2915 - In Markdown output, code blocks with classes `haskell` and `literate`
2916 will be rendered using bird tracks, and block quotations will be
2917 indented one space, so they will not be treated as Haskell code.
2918 In addition, headings will be rendered setext-style (with underlines)
2919 rather than ATX-style (with '#' characters). (This is because ghc
2920 treats '#' characters in column 1 as introducing line numbers.)
2922 - In restructured text input, "bird track" sections will be parsed
2923 as Haskell code.
2925 - In restructured text output, code blocks with class `haskell` will
2926 be rendered using bird tracks.
2928 - In LaTeX input, text in `code` environments will be parsed as
2929 Haskell code.
2931 - In LaTeX output, code blocks with class `haskell` will be rendered
2932 inside `code` environments.
2934 - In HTML output, code blocks with class `haskell` will be rendered
2935 with class `literatehaskell` and bird tracks.
2937Examples:
2939 pandoc -f markdown+lhs -t html
2941reads literate Haskell source formatted with Markdown conventions and writes
2942ordinary HTML (without bird tracks).
2944 pandoc -f markdown+lhs -t html+lhs
2946writes HTML with the Haskell code in bird tracks, so it can be copied
2947and pasted as literate Haskell source.
2949Note that GHC expects the bird tracks in the first column, so indented
2950literate code blocks (e.g. inside an itemized environment) will not be
2951picked up by the Haskell compiler.
2953## Other extensions
2955#### Extension: `empty_paragraphs` ####
2957Allows empty paragraphs. By default empty paragraphs are
2958omitted.
2960This extension can be enabled/disabled for the following formats:
2962input formats
2963: `docx`, `html`
2965output formats
2966: `docx`, `odt`, `opendocument`, `html`
2968#### Extension: `native_numbering` ####
2970Enables native numbering of figures and tables. Enumeration
2971starts at 1.
2973This extension can be enabled/disabled for the following formats:
2975output formats
2976: `odt`, `opendocument`
2978#### Extension: `styles` #### {#ext-styles}
2980When converting from docx, read all docx styles as divs (for
2981paragraph styles) and spans (for character styles) regardless
2982of whether pandoc understands the meaning of these styles.
2983This can be used with [docx custom styles](#custom-styles).
2984Disabled by default.
2986input formats
2987: `docx`
2989#### Extension: `amuse` ####
2991In the `muse` input format, this enables Text::Amuse
2992extensions to Emacs Muse markup.
2994#### Extension: `raw_markdown` ####
2996In the `ipynb` input format, this causes Markdown cells
2997to be included as raw Markdown blocks (allowing lossless
2998round-tripping) rather than being parsed. Use this only
2999when you are targeting `ipynb` or a markdown-based
3000output format.
3002#### Extension: `citations` {#org-citations}
3004Some aspects of [Pandoc's Markdown citation syntax](#citations) are also accepted
3005in `org` input.
3007#### Extension: `ntb` ####
3009In the `context` output format this enables the use of [Natural Tables
3010(TABLE)](https://wiki.contextgarden.net/TABLE) instead of the default
3011[Extreme Tables (xtables)](https://wiki.contextgarden.net/xtables).
3012Natural tables allow more fine-grained global customization but come
3013at a performance penalty compared to extreme tables.
3016# Pandoc's Markdown
3018Pandoc understands an extended and slightly revised version of
3019John Gruber's [Markdown] syntax. This document explains the syntax,
3020noting differences from standard Markdown. Except where noted, these
3021differences can be suppressed by using the `markdown_strict` format instead
3022of `markdown`. Extensions can be enabled or disabled to specify the
3023behavior more granularly. They are described in the following. See also
3024[Extensions] above, for extensions that work also on other formats.
3026## Philosophy
3028Markdown is designed to be easy to write, and, even more importantly,
3029easy to read:
3031> A Markdown-formatted document should be publishable as-is, as plain
3032> text, without looking like it's been marked up with tags or formatting
3033> instructions.
3034> -- [John Gruber](https://daringfireball.net/projects/markdown/syntax#philosophy)
3036This principle has guided pandoc's decisions in finding syntax for
3037tables, footnotes, and other extensions.
3039There is, however, one respect in which pandoc's aims are different
3040from the original aims of Markdown. Whereas Markdown was originally
3041designed with HTML generation in mind, pandoc is designed for multiple
3042output formats. Thus, while pandoc allows the embedding of raw HTML,
3043it discourages it, and provides other, non-HTMLish ways of representing
3044important document elements like definition lists, tables, mathematics, and
3045footnotes.
3047## Paragraphs
3049A paragraph is one or more lines of text followed by one or more blank lines.
3050Newlines are treated as spaces, so you can reflow your paragraphs as you like.
3051If you need a hard line break, put two or more spaces at the end of a line.
3053#### Extension: `escaped_line_breaks` ####
3055A backslash followed by a newline is also a hard line break.
3056Note: in multiline and grid table cells, this is the only way
3057to create a hard line break, since trailing spaces in the cells
3058are ignored.
3060## Headings
3062There are two kinds of headings: Setext and ATX.
3064### Setext-style headings ###
3066A setext-style heading is a line of text "underlined" with a row of `=` signs
3067(for a level-one heading) or `-` signs (for a level-two heading):
3069 A level-one heading
3070 ===================
3072 A level-two heading
3073 -------------------
3075The heading text can contain inline formatting, such as emphasis (see
3076[Inline formatting], below).
3079### ATX-style headings ###
3081An ATX-style heading consists of one to six `#` signs and a line of
3082text, optionally followed by any number of `#` signs. The number of
3083`#` signs at the beginning of the line is the heading level:
3085 ## A level-two heading
3087 ### A level-three heading ###
3089As with setext-style headings, the heading text can contain formatting:
3091 # A level-one heading with a [link](/url) and *emphasis*
3093#### Extension: `blank_before_header` ####
3095Standard Markdown syntax does not require a blank line before a heading.
3096Pandoc does require this (except, of course, at the beginning of the
3097document). The reason for the requirement is that it is all too easy for a
3098`#` to end up at the beginning of a line by accident (perhaps through line
3099wrapping). Consider, for example:
3101 I like several of their flavors of ice cream:
3102 #22, for example, and #5.
3104#### Extension: `space_in_atx_header` ####
3106Many Markdown implementations do not require a space between the
3107opening `#`s of an ATX heading and the heading text, so that
3108`#5 bolt` and `#hashtag` count as headings. With this extension,
3109pandoc does require the space.
3111### Heading identifiers ###
3113See also the [`auto_identifiers` extension](#extension-auto_identifiers) above.
3115#### Extension: `header_attributes` ####
3117Headings can be assigned attributes using this syntax at the end
3118of the line containing the heading text:
3120 {#identifier .class .class key=value key=value}
3122Thus, for example, the following headings will all be assigned the identifier
3123`foo`:
3125 # My heading {#foo}
3127 ## My heading ## {#foo}
3129 My other heading {#foo}
3130 ---------------
3132(This syntax is compatible with [PHP Markdown Extra].)
3134Note that although this syntax allows assignment of classes and key/value
3135attributes, writers generally don't use all of this information. Identifiers,
3136classes, and key/value attributes are used in HTML and HTML-based formats such
3137as EPUB and slidy. Identifiers are used for labels and link anchors in the
3138LaTeX, ConTeXt, Textile, Jira markup, and AsciiDoc writers.
3140Headings with the class `unnumbered` will not be numbered, even if
3141`--number-sections` is specified. A single hyphen (`-`) in an attribute
3142context is equivalent to `.unnumbered`, and preferable in non-English
3143documents. So,
3145 # My heading {-}
3147is just the same as
3149 # My heading {.unnumbered}
3151If the `unlisted` class is present in addition to `unnumbered`,
3152the heading will not be included in a table of contents.
3153(Currently this feature is only implemented for certain
3154formats: those based on LaTeX and HTML, PowerPoint, and RTF.)
3156#### Extension: `implicit_header_references` ####
3158Pandoc behaves as if reference links have been defined for each heading.
3159So, to link to a heading
3161 # Heading identifiers in HTML
3163you can simply write
3165 [Heading identifiers in HTML]
3169 [Heading identifiers in HTML][]
3173 [the section on heading identifiers][heading identifiers in
3174 HTML]
3176instead of giving the identifier explicitly:
3178 [Heading identifiers in HTML](#heading-identifiers-in-html)
3180If there are multiple headings with identical text, the corresponding
3181reference will link to the first one only, and you will need to use explicit
3182links to link to the others, as described above.
3184Like regular reference links, these references are case-insensitive.
3186Explicit link reference definitions always take priority over
3187implicit heading references. So, in the following example, the
3188link will point to `bar`, not to `#foo`:
3190 # Foo
3192 [foo]: bar
3194 See [foo]
3196## Block quotations
3198Markdown uses email conventions for quoting blocks of text.
3199A block quotation is one or more paragraphs or other block elements
3200(such as lists or headings), with each line preceded by a `>` character
3201and an optional space. (The `>` need not start at the left margin, but
3202it should not be indented more than three spaces.)
3204 > This is a block quote. This
3205 > paragraph has two lines.
3207 > 1. This is a list inside a block quote.
3208 > 2. Second item.
3210A "lazy" form, which requires the `>` character only on the first
3211line of each block, is also allowed:
3213 > This is a block quote. This
3214 paragraph has two lines.
3216 > 1. This is a list inside a block quote.
3217 2. Second item.
3219Among the block elements that can be contained in a block quote are
3220other block quotes. That is, block quotes can be nested:
3222 > This is a block quote.
3224 > > A block quote within a block quote.
3226If the `>` character is followed by an optional space, that space
3227will be considered part of the block quote marker and not part of
3228the indentation of the contents. Thus, to put an indented code
3229block in a block quote, you need five spaces after the `>`:
3231 > code
3233#### Extension: `blank_before_blockquote` ####
3235Standard Markdown syntax does not require a blank line before a block
3236quote. Pandoc does require this (except, of course, at the beginning of the
3237document). The reason for the requirement is that it is all too easy for a
3238`>` to end up at the beginning of a line by accident (perhaps through line
3239wrapping). So, unless the `markdown_strict` format is used, the following does
3240not produce a nested block quote in pandoc:
3242 > This is a block quote.
3243 >> Nested.
3246## Verbatim (code) blocks
3248### Indented code blocks ###
3250A block of text indented four spaces (or one tab) is treated as verbatim
3251text: that is, special characters do not trigger special formatting,
3252and all spaces and line breaks are preserved. For example,
3254 if (a > 3) {
3255 moveShip(5 * gravity, DOWN);
3258The initial (four space or one tab) indentation is not considered part
3259of the verbatim text, and is removed in the output.
3261Note: blank lines in the verbatim text need not begin with four spaces.
3264### Fenced code blocks ###
3266#### Extension: `fenced_code_blocks` ####
3268In addition to standard indented code blocks, pandoc supports
3269*fenced* code blocks. These begin with a row of three or more
3270tildes (`~`) and end with a row of tildes that must be at least as long as
3271the starting row. Everything between these lines is treated as code. No
3272indentation is necessary:
3274 ~~~~~~~
3275 if (a > 3) {
3276 moveShip(5 * gravity, DOWN);
3278 ~~~~~~~
3280Like regular code blocks, fenced code blocks must be separated
3281from surrounding text by blank lines.
3283If the code itself contains a row of tildes or backticks, just use a longer
3284row of tildes or backticks at the start and end:
3286 ~~~~~~~~~~~~~~~~
3287 ~~~~~~~~~~
3288 code including tildes
3289 ~~~~~~~~~~
3290 ~~~~~~~~~~~~~~~~
3292#### Extension: `backtick_code_blocks` ####
3294Same as `fenced_code_blocks`, but uses backticks (`` ` ``) instead of tildes
3295(`~`).
3297#### Extension: `fenced_code_attributes` ####
3299Optionally, you may attach attributes to fenced or backtick code block using
3300this syntax:
3302 ~~~~ {#mycode .haskell .numberLines startFrom="100"}
3303 qsort [] = []
3304 qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
3305 qsort (filter (>= x) xs)
3306 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3308Here `mycode` is an identifier, `haskell` and `numberLines` are classes, and
3309`startFrom` is an attribute with value `100`. Some output formats can use this
3310information to do syntax highlighting. Currently, the only output formats
3311that uses this information are HTML, LaTeX, Docx, Ms, and PowerPoint. If
3312highlighting is supported for your output format and language, then the code
3313block above will appear highlighted, with numbered lines. (To see which
3314languages are supported, type `pandoc --list-highlight-languages`.) Otherwise,
3315the code block above will appear as follows:
3317 <pre id="mycode" class="haskell numberLines" startFrom="100">
3318 <code>
3319 ...
3320 </code>
3321 </pre>
3323The `numberLines` (or `number-lines`) class will cause the lines
3324of the code block to be numbered, starting with `1` or the value
3325of the `startFrom` attribute. The `lineAnchors` (or
3326`line-anchors`) class will cause the lines to be clickable
3327anchors in HTML output.
3329A shortcut form can also be used for specifying the language of
3330the code block:
3332 ```haskell
3333 qsort [] = []
3334 ```
3336This is equivalent to:
3338 ``` {.haskell}
3339 qsort [] = []
3340 ```
3342If the `fenced_code_attributes` extension is disabled, but
3343input contains class attribute(s) for the code block, the first
3344class attribute will be printed after the opening fence as a bare
3345word.
3347To prevent all highlighting, use the `--no-highlight` flag.
3348To set the highlighting style, use `--highlight-style`.
3349For more information on highlighting, see [Syntax highlighting],
3350below.
3352## Line blocks
3354#### Extension: `line_blocks` ####
3356A line block is a sequence of lines beginning with a vertical bar (`|`)
3357followed by a space. The division into lines will be preserved in
3358the output, as will any leading spaces; otherwise, the lines will
3359be formatted as Markdown. This is useful for verse and addresses:
3361 | The limerick packs laughs anatomical
3362 | In space that is quite economical.
3363 | But the good ones I've seen
3364 | So seldom are clean
3365 | And the clean ones so seldom are comical
3367 | 200 Main St.
3368 | Berkeley, CA 94718
3370The lines can be hard-wrapped if needed, but the continuation
3371line must begin with a space.
3373 | The Right Honorable Most Venerable and Righteous Samuel L.
3374 Constable, Jr.
3375 | 200 Main St.
3376 | Berkeley, CA 94718
3378This syntax is borrowed from [reStructuredText].
3380## Lists
3382### Bullet lists ###
3384A bullet list is a list of bulleted list items. A bulleted list
3385item begins with a bullet (`*`, `+`, or `-`). Here is a simple
3386example:
3388 * one
3389 * two
3390 * three
3392This will produce a "compact" list. If you want a "loose" list, in which
3393each item is formatted as a paragraph, put spaces between the items:
3395 * one
3397 * two
3399 * three
3401The bullets need not be flush with the left margin; they may be
3402indented one, two, or three spaces. The bullet must be followed
3403by whitespace.
3405List items look best if subsequent lines are flush with the first
3406line (after the bullet):
3408 * here is my first
3409 list item.
3410 * and my second.
3412But Markdown also allows a "lazy" format:
3414 * here is my first
3415 list item.
3416 * and my second.
3418### Block content in list items ###
3420A list item may contain multiple paragraphs and other block-level
3421content. However, subsequent paragraphs must be preceded by a blank line
3422and indented to line up with the first non-space content after
3423the list marker.
3425 * First paragraph.
3427 Continued.
3429 * Second paragraph. With a code block, which must be indented
3430 eight spaces:
3432 { code }
3434Exception: if the list marker is followed by an indented code
3435block, which must begin 5 spaces after the list marker, then
3436subsequent paragraphs must begin two columns after the last
3437character of the list marker:
3439 * code
3441 continuation paragraph
3443List items may include other lists. In this case the preceding blank
3444line is optional. The nested list must be indented to line up with
3445the first non-space character after the list marker of the
3446containing list item.
3448 * fruits
3449 + apples
3450 - macintosh
3451 - red delicious
3452 + pears
3453 + peaches
3454 * vegetables
3455 + broccoli
3456 + chard
3458As noted above, Markdown allows you to write list items "lazily," instead of
3459indenting continuation lines. However, if there are multiple paragraphs or
3460other blocks in a list item, the first line of each must be indented.
3462 + A lazy, lazy, list
3463 item.
3465 + Another one; this looks
3466 bad but is legal.
3468 Second paragraph of second
3469 list item.
3471### Ordered lists ###
3473Ordered lists work just like bulleted lists, except that the items
3474begin with enumerators rather than bullets.
3476In standard Markdown, enumerators are decimal numbers followed
3477by a period and a space. The numbers themselves are ignored, so
3478there is no difference between this list:
3480 1. one
3481 2. two
3482 3. three
3484and this one:
3486 5. one
3487 7. two
3488 1. three
3490#### Extension: `fancy_lists` ####
3492Unlike standard Markdown, pandoc allows ordered list items to be marked
3493with uppercase and lowercase letters and roman numerals, in addition to
3494Arabic numerals. List markers may be enclosed in parentheses or followed by a
3495single right-parentheses or period. They must be separated from the
3496text that follows by at least one space, and, if the list marker is a
3497capital letter with a period, by at least two spaces.[^2]
3499[^2]: The point of this rule is to ensure that normal paragraphs
3500 starting with people's initials, like
3502 B. Russell was an English philosopher.
3504 do not get treated as list items.
3506 This rule will not prevent
3508 (C) 2007 Joe Smith
3510 from being interpreted as a list item. In this case, a backslash
3511 escape can be used:
3513 (C\) 2007 Joe Smith
3515The `fancy_lists` extension also allows '`#`' to be used as an
3516ordered list marker in place of a numeral:
3518 #. one
3519 #. two
3521#### Extension: `startnum` ####
3523Pandoc also pays attention to the type of list marker used, and to the
3524starting number, and both of these are preserved where possible in the
3525output format. Thus, the following yields a list with numbers followed
3526by a single parenthesis, starting with 9, and a sublist with lowercase
3527roman numerals:
3529 9) Ninth
3530 10) Tenth
3531 11) Eleventh
3532 i. subone
3533 ii. subtwo
3534 iii. subthree
3536Pandoc will start a new list each time a different type of list
3537marker is used. So, the following will create three lists:
3539 (2) Two
3540 (5) Three
3541 1. Four
3542 * Five
3544If default list markers are desired, use `#.`:
3546 #. one
3547 #. two
3548 #. three
3550#### Extension: `task_lists` ####
3552Pandoc supports task lists, using the syntax of GitHub-Flavored Markdown.
3554 - [ ] an unchecked task list item
3555 - [x] checked item
3557### Definition lists ###
3559#### Extension: `definition_lists` ####
3561Pandoc supports definition lists, using the syntax of
3562[PHP Markdown Extra] with some extensions.[^3]
3564 Term 1
3566 : Definition 1
3568 Term 2 with *inline markup*
3570 : Definition 2
3572 { some code, part of Definition 2 }
3574 Third paragraph of definition 2.
3576Each term must fit on one line, which may optionally be followed by
3577a blank line, and must be followed by one or more definitions.
3578A definition begins with a colon or tilde, which may be indented one
3579or two spaces.
3581A term may have multiple definitions, and each definition may consist of one or
3582more block elements (paragraph, code block, list, etc.), each indented four
3583spaces or one tab stop. The body of the definition (including the first line,
3584aside from the colon or tilde) should be indented four spaces. However,
3585as with other Markdown lists, you can "lazily" omit indentation except
3586at the beginning of a paragraph or other block element:
3588 Term 1
3590 : Definition
3591 with lazy continuation.
3593 Second paragraph of the definition.
3595If you leave space before the definition (as in the example above),
3596the text of the definition will be treated as a paragraph. In some
3597output formats, this will mean greater spacing between term/definition
3598pairs. For a more compact definition list, omit the space before the
3599definition:
3601 Term 1
3602 ~ Definition 1
3604 Term 2
3605 ~ Definition 2a
3606 ~ Definition 2b
3608Note that space between items in a definition list is required.
3609(A variant that loosens this requirement, but disallows "lazy"
3610hard wrapping, can be activated with `compact_definition_lists`: see
3611[Non-pandoc extensions], below.)
3613[^3]: I have been influenced by the suggestions of [David Wheeler](https://justatheory.com/2009/02/modest-markdown-proposal/).
3615### Numbered example lists ###
3617#### Extension: `example_lists` ####
3619The special list marker `@` can be used for sequentially numbered
3620examples. The first list item with a `@` marker will be numbered '1',
3621the next '2', and so on, throughout the document. The numbered examples
3622need not occur in a single list; each new list using `@` will take up
3623where the last stopped. So, for example:
3625 (@) My first example will be numbered (1).
3626 (@) My second example will be numbered (2).
3628 Explanation of examples.
3630 (@) My third example will be numbered (3).
3632Numbered examples can be labeled and referred to elsewhere in the
3633document:
3635 (@good) This is a good example.
3637 As (@good) illustrates, ...
3639The label can be any string of alphanumeric characters, underscores,
3640or hyphens.
3642Note: continuation paragraphs in example lists must always
3643be indented four spaces, regardless of the length of the
3644list marker. That is, example lists always behave as if the
3645`four_space_rule` extension is set. This is because example
3646labels tend to be long, and indenting content to the
3647first non-space character after the label would be awkward.
3650### Ending a list ###
3652What if you want to put an indented code block after a list?
3654 - item one
3655 - item two
3657 { my code block }
3659Trouble! Here pandoc (like other Markdown implementations) will treat
3660`{ my code block }` as the second paragraph of item two, and not as
3661a code block.
3663To "cut off" the list after item two, you can insert some non-indented
3664content, like an HTML comment, which won't produce visible output in
3665any format:
3667 - item one
3668 - item two
3670 <!-- end of list -->
3672 { my code block }
3674You can use the same trick if you want two consecutive lists instead
3675of one big list:
3677 1. one
3678 2. two
3679 3. three
3681 <!-- -->
3683 1. uno
3684 2. dos
3685 3. tres
3687## Horizontal rules
3689A line containing a row of three or more `*`, `-`, or `_` characters
3690(optionally separated by spaces) produces a horizontal rule:
3692 * * * *
3694 ---------------
3697## Tables
3699Four kinds of tables may be used. The first three kinds presuppose the use of
3700a fixed-width font, such as Courier. The fourth kind can be used with
3701proportionally spaced fonts, as it does not require lining up columns.
3703#### Extension: `table_captions` ####
3705A caption may optionally be provided with all 4 kinds of tables (as
3706illustrated in the examples below). A caption is a paragraph beginning
3707with the string `Table:` (or just `:`), which will be stripped off.
3708It may appear either before or after the table.
3710#### Extension: `simple_tables` ####
3712Simple tables look like this:
3714 Right Left Center Default
3715 ------- ------ ---------- -------
3716 12 12 12 12
3717 123 123 123 123
3718 1 1 1 1
3720 Table: Demonstration of simple table syntax.
3722The header and table rows must each fit on one line. Column
3723alignments are determined by the position of the header text relative
3724to the dashed line below it:[^4]
3726 - If the dashed line is flush with the header text on the right side
3727 but extends beyond it on the left, the column is right-aligned.
3728 - If the dashed line is flush with the header text on the left side
3729 but extends beyond it on the right, the column is left-aligned.
3730 - If the dashed line extends beyond the header text on both sides,
3731 the column is centered.
3732 - If the dashed line is flush with the header text on both sides,
3733 the default alignment is used (in most cases, this will be left).
3735[^4]: This scheme is due to Michel Fortin, who proposed it on the
3736 [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).
3738The table must end with a blank line, or a line of dashes followed by
3739a blank line.
3741The column header row may be omitted, provided a dashed line is used
3742to end the table. For example:
3744 ------- ------ ---------- -------
3745 12 12 12 12
3746 123 123 123 123
3747 1 1 1 1
3748 ------- ------ ---------- -------
3750When the header row is omitted, column alignments are determined on the basis
3751of the first line of the table body. So, in the tables above, the columns
3752would be right, left, center, and right aligned, respectively.
3754#### Extension: `multiline_tables` ####
3756Multiline tables allow header and table rows to span multiple lines
3757of text (but cells that span multiple columns or rows of the table are
3758not supported). Here is an example:
3760 -------------------------------------------------------------
3761 Centered Default Right Left
3762 Header Aligned Aligned Aligned
3763 ----------- ------- --------------- -------------------------
3764 First row 12.0 Example of a row that
3765 spans multiple lines.
3767 Second row 5.0 Here's another one. Note
3768 the blank line between
3769 rows.
3770 -------------------------------------------------------------
3772 Table: Here's the caption. It, too, may span
3773 multiple lines.
3775These work like simple tables, but with the following differences:
3777 - They must begin with a row of dashes, before the header text
3778 (unless the header row is omitted).
3779 - They must end with a row of dashes, then a blank line.
3780 - The rows must be separated by blank lines.
3782In multiline tables, the table parser pays attention to the widths of
3783the columns, and the writers try to reproduce these relative widths in
3784the output. So, if you find that one of the columns is too narrow in the
3785output, try widening it in the Markdown source.
3787The header may be omitted in multiline tables as well as simple tables:
3789 ----------- ------- --------------- -------------------------
3790 First row 12.0 Example of a row that
3791 spans multiple lines.
3793 Second row 5.0 Here's another one. Note
3794 the blank line between
3795 rows.
3796 ----------- ------- --------------- -------------------------
3798 : Here's a multiline table without a header.
3800It is possible for a multiline table to have just one row, but the row
3801should be followed by a blank line (and then the row of dashes that ends
3802the table), or the table may be interpreted as a simple table.
3804#### Extension: `grid_tables` ####
3806Grid tables look like this:
3808 : Sample grid table.
3810 +---------------+---------------+--------------------+
3811 | Fruit | Price | Advantages |
3812 +===============+===============+====================+
3813 | Bananas | $1.34 | - built-in wrapper |
3814 | | | - bright color |
3815 +---------------+---------------+--------------------+
3816 | Oranges | $2.10 | - cures scurvy |
3817 | | | - tasty |
3818 +---------------+---------------+--------------------+
3820The row of `=`s separates the header from the table body, and can be
3821omitted for a headerless table. The cells of grid tables may contain
3822arbitrary block elements (multiple paragraphs, code blocks, lists,
3823etc.). Cells that span multiple columns or rows are not
3824supported. Grid tables can be created easily using Emacs' table-mode
3825(`M-x table-insert`).
3827Alignments can be specified as with pipe tables, by putting
3828colons at the boundaries of the separator line after the
3829header:
3831 +---------------+---------------+--------------------+
3832 | Right | Left | Centered |
3833 +==============:+:==============+:==================:+
3834 | Bananas | $1.34 | built-in wrapper |
3835 +---------------+---------------+--------------------+
3837For headerless tables, the colons go on the top line instead:
3839 +--------------:+:--------------+:------------------:+
3840 | Right | Left | Centered |
3841 +---------------+---------------+--------------------+
3843##### Grid Table Limitations #####
3845Pandoc does not support grid tables with row spans or column spans.
3846This means that neither variable numbers of columns across rows nor
3847variable numbers of rows across columns are supported by Pandoc.
3848All grid tables must have the same number of columns in each row,
3849and the same number of rows in each column. For example, the
3850Docutils [sample grid tables] will not render as expected with
3851Pandoc.
3853[sample grid tables]: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#grid-tables
3856#### Extension: `pipe_tables` ####
3858Pipe tables look like this:
3860 | Right | Left | Default | Center |
3861 |------:|:-----|---------|:------:|
3862 | 12 | 12 | 12 | 12 |
3863 | 123 | 123 | 123 | 123 |
3864 | 1 | 1 | 1 | 1 |
3866 : Demonstration of pipe table syntax.
3868The syntax is identical to [PHP Markdown Extra tables]. The beginning and
3869ending pipe characters are optional, but pipes are required between all
3870columns. The colons indicate column alignment as shown. The header
3871cannot be omitted. To simulate a headerless table, include a header
3872with blank cells.
3874Since the pipes indicate column boundaries, columns need not be vertically
3875aligned, as they are in the above example. So, this is a perfectly
3876legal (though ugly) pipe table:
3878 fruit| price
3879 -----|-----:
3880 apple|2.05
3881 pear|1.37
3882 orange|3.09
3884The cells of pipe tables cannot contain block elements like paragraphs
3885and lists, and cannot span multiple lines. If a pipe table contains a
3886row whose Markdown content is wider than the column width (see
3887`--columns`), then the table will take up the full text width and
3888the cell contents will wrap, with the relative cell widths determined
3889by the number of dashes in the line separating the table header from
3890the table body. (For example `---|-` would make the first column 3/4
3891and the second column 1/4 of the full text width.)
3892On the other hand, if no lines are wider than column width, then
3893cell contents will not be wrapped, and the cells will be sized
3894to their contents.
3896Note: pandoc also recognizes pipe tables of the following
3897form, as can be produced by Emacs' orgtbl-mode:
3899 | One | Two |
3900 |-----+-------|
3901 | my | table |
3902 | is | nice |
3904The difference is that `+` is used instead of `|`. Other orgtbl features
3905are not supported. In particular, to get non-default column alignment,
3906you'll need to add colons as above.
3908[PHP Markdown Extra tables]: https://michelf.ca/projects/php-markdown/extra/#table
3910## Metadata blocks
3912#### Extension: `pandoc_title_block` ####
3914If the file begins with a title block
3916 % title
3917 % author(s) (separated by semicolons)
3918 % date
3920it will be parsed as bibliographic information, not regular text. (It
3921will be used, for example, in the title of standalone LaTeX or HTML
3922output.) The block may contain just a title, a title and an author,
3923or all three elements. If you want to include an author but no
3924title, or a title and a date but no author, you need a blank line:
3926```
3928% Author
3929```
3931```
3932% My title
3934% June 15, 2006
3935```
3937The title may occupy multiple lines, but continuation lines must
3938begin with leading space, thus:
3940```
3941% My title
3942 on multiple lines
3943```
3945If a document has multiple authors, the authors may be put on
3946separate lines with leading space, or separated by semicolons, or
3947both. So, all of the following are equivalent:
3949```
3950% Author One
3951 Author Two
3952```
3954```
3955% Author One; Author Two
3956```
3958```
3959% Author One;
3960 Author Two
3961```
3963The date must fit on one line.
3965All three metadata fields may contain standard inline formatting
3966(italics, links, footnotes, etc.).
3968Title blocks will always be parsed, but they will affect the output only
3969when the `--standalone` (`-s`) option is chosen. In HTML output, titles
3970will appear twice: once in the document head -- this is the title that
3971will appear at the top of the window in a browser -- and once at the
3972beginning of the document body. The title in the document head can have
3973an optional prefix attached (`--title-prefix` or `-T` option). The title
3974in the body appears as an H1 element with class "title", so it can be
3975suppressed or reformatted with CSS. If a title prefix is specified with
3976`-T` and no title block appears in the document, the title prefix will
3977be used by itself as the HTML title.
3979The man page writer extracts a title, man page section number, and
3980other header and footer information from the title line. The title
3981is assumed to be the first word on the title line, which may optionally
3982end with a (single-digit) section number in parentheses. (There should
3983be no space between the title and the parentheses.) Anything after
3984this is assumed to be additional footer and header text. A single pipe
3985character (`|`) should be used to separate the footer text from the header
3986text. Thus,
3988 % PANDOC(1)
3990will yield a man page with the title `PANDOC` and section 1.
3992 % PANDOC(1) Pandoc User Manuals
3994will also have "Pandoc User Manuals" in the footer.
3996 % PANDOC(1) Pandoc User Manuals | Version 4.0
3998will also have "Version 4.0" in the header.
4000#### Extension: `yaml_metadata_block` ####
4002A [YAML] metadata block is a valid YAML object, delimited by a line of three
4003hyphens (`---`) at the top and a line of three hyphens (`---`) or three dots
4004(`...`) at the bottom. A YAML metadata block may occur anywhere in the
4005document, but if it is not at the beginning, it must be preceded by a blank
4006line. (Note that, because of the way pandoc concatenates input files when
4007several are provided, you may also keep the metadata in a separate YAML file
4008and pass it to pandoc as an argument, along with your Markdown files:
4010 pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html
4012Just be sure that the YAML file begins with `---` and ends with `---` or
4013`...`.) Alternatively, you can use the `--metadata-file` option. Using
4014that approach however, you cannot reference content (like footnotes)
4015from the main markdown input document.
4017Metadata will be taken from the fields of the YAML object and added to any
4018existing document metadata. Metadata can contain lists and objects (nested
4019arbitrarily), but all string scalars will be interpreted as Markdown. Fields
4020with names ending in an underscore will be ignored by pandoc. (They may be
4021given a role by external processors.) Field names must not be
4022interpretable as YAML numbers or boolean values (so, for
4023example, `yes`, `True`, and `15` cannot be used as field names).
4025A document may contain multiple metadata blocks. If two
4026metadata blocks attempt to set the same field, the value from
4027the second block will be taken.
4029When pandoc is used with `-t markdown` to create a Markdown document,
4030a YAML metadata block will be produced only if the `-s/--standalone`
4031option is used. All of the metadata will appear in a single block
4032at the beginning of the document.
4034Note that [YAML] escaping rules must be followed. Thus, for example,
4035if a title contains a colon, it must be quoted. The pipe character
4036(`|`) can be used to begin an indented block that will be interpreted
4037literally, without need for escaping. This form is necessary
4038when the field contains blank lines or block-level formatting:
4040 ---
4041 title: 'This is the title: it contains a colon'
4042 author:
4043 - Author One
4044 - Author Two
4045 keywords: [nothing, nothingness]
4046 abstract: |
4047 This is the abstract.
4049 It consists of two paragraphs.
4050 ...
4052Template variables will be set automatically from the metadata. Thus, for
4053example, in writing HTML, the variable `abstract` will be set to the HTML
4054equivalent of the Markdown in the `abstract` field:
4056 <p>This is the abstract.</p>
4057 <p>It consists of two paragraphs.</p>
4059Variables can contain arbitrary YAML structures, but the template must match
4060this structure. The `author` variable in the default templates expects a
4061simple list or string, but can be changed to support more complicated
4062structures. The following combination, for example, would add an affiliation
4063to the author if one is given:
4065 ---
4066 title: The document title
4067 author:
4068 - name: Author One
4069 affiliation: University of Somewhere
4070 - name: Author Two
4071 affiliation: University of Nowhere
4072 ...
4074To use the structured authors in the example above, you would need a custom
4075template:
4077 $for(author)$
4078 $if(author.name)$
4079 $author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$
4080 $else$
4081 $author$
4082 $endif$
4083 $endfor$
4085Raw content to include in the document's header may be specified
4086using `header-includes`; however, it is important to mark up
4087this content as raw code for a particular output format, using
4088the [`raw_attribute` extension](#extension-raw_attribute)), or it
4089will be interpreted as markdown. For example:
4091 header-includes:
4092 - |
4093 ```{=latex}
4094 \let\oldsection\section
4095 \renewcommand{\section}[1]{\clearpage\oldsection{#1}}
4096 ```
4098## Backslash escapes
4100#### Extension: `all_symbols_escapable` ####
4102Except inside a code block or inline code, any punctuation or space
4103character preceded by a backslash will be treated literally, even if it
4104would normally indicate formatting. Thus, for example, if one writes
4106 *\*hello\**
4108one will get
4110 <em>*hello*</em>
4112instead of
4114 <strong>hello</strong>
4116This rule is easier to remember than standard Markdown's rule,
4117which allows only the following characters to be backslash-escaped:
4119 \`*_{}[]()>#+-.!
4121(However, if the `markdown_strict` format is used, the standard Markdown rule
4122will be used.)
4124A backslash-escaped space is parsed as a nonbreaking space. In TeX output,
4125it will appear as `~`. In HTML and XML output, it will appear as a
4126literal unicode nonbreaking space character (note that it will thus
4127actually look "invisible" in the generated HTML source; you can still
4128use the `--ascii` command-line option to make it appear as an explicit
4129entity).
4131A backslash-escaped newline (i.e. a backslash occurring at the end of
4132a line) is parsed as a hard line break. It will appear in TeX output as
4133`\\` and in HTML as `<br />`. This is a nice alternative to
4134Markdown's "invisible" way of indicating hard line breaks using
4135two trailing spaces on a line.
4137Backslash escapes do not work in verbatim contexts.
4139## Inline formatting
4141### Emphasis ###
4143To *emphasize* some text, surround it with `*`s or `_`, like this:
4145 This text is _emphasized with underscores_, and this
4146 is *emphasized with asterisks*.
4148Double `*` or `_` produces **strong emphasis**:
4150 This is **strong emphasis** and __with underscores__.
4152A `*` or `_` character surrounded by spaces, or backslash-escaped,
4153will not trigger emphasis:
4155 This is * not emphasized *, and \*neither is this\*.
4157#### Extension: `intraword_underscores` ####
4159Because `_` is sometimes used inside words and identifiers,
4160pandoc does not interpret a `_` surrounded by alphanumeric
4161characters as an emphasis marker. If you want to emphasize
4162just part of a word, use `*`:
4164 feas*ible*, not feas*able*.
4167### Strikeout ###
4169#### Extension: `strikeout` ####
4171To strikeout a section of text with a horizontal line, begin and end it
4172with `~~`. Thus, for example,
4174 This ~~is deleted text.~~
4177### Superscripts and subscripts ###
4179#### Extension: `superscript`, `subscript` ####
4181Superscripts may be written by surrounding the superscripted text by `^`
4182characters; subscripts may be written by surrounding the subscripted
4183text by `~` characters. Thus, for example,
4185 H~2~O is a liquid. 2^10^ is 1024.
4187The text between `^...^` or `~...~` may not contain spaces or
4188newlines. If the superscripted or subscripted text contains
4189spaces, these spaces must be escaped with backslashes. (This is
4190to prevent accidental superscripting and subscripting through
4191the ordinary use of `~` and `^`, and also bad interactions with
4192footnotes.) Thus, if you want the letter P with 'a cat' in
4193subscripts, use `P~a\ cat~`, not `P~a cat~`.
4195### Verbatim ###
4197To make a short span of text verbatim, put it inside backticks:
4199 What is the difference between `>>=` and `>>`?
4201If the verbatim text includes a backtick, use double backticks:
4203 Here is a literal backtick `` ` ``.
4205(The spaces after the opening backticks and before the closing
4206backticks will be ignored.)
4208The general rule is that a verbatim span starts with a string
4209of consecutive backticks (optionally followed by a space)
4210and ends with a string of the same number of backticks (optionally
4211preceded by a space).
4213Note that backslash-escapes (and other Markdown constructs) do not
4214work in verbatim contexts:
4216 This is a backslash followed by an asterisk: `\*`.
4218#### Extension: `inline_code_attributes` ####
4220Attributes can be attached to verbatim text, just as with
4221[fenced code blocks]:
4223 `<$>`{.haskell}
4225### Small caps ###
4227To write small caps, use the `smallcaps` class:
4229 [Small caps]{.smallcaps}
4231Or, without the `bracketed_spans` extension:
4233 <span class="smallcaps">Small caps</span>
4235For compatibility with other Markdown flavors, CSS is also supported:
4237 <span style="font-variant:small-caps;">Small caps</span>
4239This will work in all output formats that support small caps.
4242## Math
4244#### Extension: `tex_math_dollars` ####
4246Anything between two `$` characters will be treated as TeX math. The
4247opening `$` must have a non-space character immediately to its right,
4248while the closing `$` must have a non-space character immediately to its
4249left, and must not be followed immediately by a digit. Thus,
4250`$20,000 and $30,000` won't parse as math. If for some reason
4251you need to enclose text in literal `$` characters, backslash-escape
4252them and they won't be treated as math delimiters.
4254For display math, use `$$` delimiters. (In this case, the delimiters
4255may be separated from the formula by whitespace.)
4257TeX math will be printed in all output formats. How it is rendered
4258depends on the output format:
4260LaTeX
4261 ~ It will appear verbatim surrounded by `\(...\)` (for inline
4262 math) or `\[...\]` (for display math).
4264Markdown, Emacs Org mode, ConTeXt, ZimWiki
4265 ~ It will appear verbatim surrounded by `$...$` (for inline
4266 math) or `$$...$$` (for display math).
4268XWiki
4269 ~ It will appear verbatim surrounded by `{{formula}}..{{/formula}}`.
4271reStructuredText
4272 ~ It will be rendered using an [interpreted text role `:math:`].
4274AsciiDoc
4275 ~ For AsciiDoc output format (`-t asciidoc`) it will appear verbatim
4276 surrounded by `latexmath:[$...$]` (for inline math) or
4277 `[latexmath]++++\[...\]+++` (for display math).
4278 For AsciiDoctor output format (`-t asciidoctor`) the LaTex delimiters
4279 (`$..$` and `\[..\]`) are omitted.
4281Texinfo
4282 ~ It will be rendered inside a `@math` command.
4284roff man, Jira markup
4285 ~ It will be rendered verbatim without `$`'s.
4287MediaWiki, DokuWiki
4288 ~ It will be rendered inside `<math>` tags.
4290Textile
4291 ~ It will be rendered inside `<span class="math">` tags.
4293RTF, OpenDocument
4294 ~ It will be rendered, if possible, using Unicode characters,
4295 and will otherwise appear verbatim.
4297ODT
4298 ~ It will be rendered, if possible, using MathML.
4300DocBook
4301 ~ If the `--mathml` flag is used, it will be rendered using MathML
4302 in an `inlineequation` or `informalequation` tag. Otherwise it
4303 will be rendered, if possible, using Unicode characters.
4305Docx
4306 ~ It will be rendered using OMML math markup.
4308FictionBook2
4309 ~ If the `--webtex` option is used, formulas are rendered as images
4310 using CodeCogs or other compatible web service, downloaded
4311 and embedded in the e-book. Otherwise, they will appear verbatim.
4313HTML, Slidy, DZSlides, S5, EPUB
4314 ~ The way math is rendered in HTML will depend on the
4315 command-line options selected. Therefore see [Math rendering in HTML]
4316 above.
4318[interpreted text role `:math:`]: https://docutils.sourceforge.io/docs/ref/rst/roles.html#math
4320## Raw HTML
4322#### Extension: `raw_html` ####
4324Markdown allows you to insert raw HTML (or DocBook) anywhere in a document
4325(except verbatim contexts, where `<`, `>`, and `&` are interpreted
4326literally). (Technically this is not an extension, since standard
4327Markdown allows it, but it has been made an extension so that it can
4328be disabled if desired.)
4330The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,
4331DZSlides, EPUB, Markdown, CommonMark, Emacs Org mode, and Textile
4332output, and suppressed in other formats.
4334For a more explicit way of including raw HTML in a Markdown
4335document, see the [`raw_attribute` extension][Extension: `raw_attribute`].
4337In the CommonMark format, if `raw_html` is enabled, superscripts,
4338subscripts, strikeouts and small capitals will be represented as HTML.
4339Otherwise, plain-text fallbacks will be used. Note that even if
4340`raw_html` is disabled, tables will be rendered with HTML syntax if
4341they cannot use pipe syntax.
4343#### Extension: `markdown_in_html_blocks` ####
4345Standard Markdown allows you to include HTML "blocks": blocks
4346of HTML between balanced tags that are separated from the surrounding text
4347with blank lines, and start and end at the left margin. Within
4348these blocks, everything is interpreted as HTML, not Markdown;
4349so (for example), `*` does not signify emphasis.
4351Pandoc behaves this way when the `markdown_strict` format is used; but
4352by default, pandoc interprets material between HTML block tags as Markdown.
4353Thus, for example, pandoc will turn
4355 <table>
4356 <tr>
4357 <td>*one*</td>
4358 <td>[a link](https://google.com)</td>
4359 </tr>
4360 </table>
4362into
4364 <table>
4365 <tr>
4366 <td><em>one</em></td>
4367 <td><a href="https://google.com">a link</a></td>
4368 </tr>
4369 </table>
4371whereas `Markdown.pl` will preserve it as is.
4373There is one exception to this rule: text between `<script>` and
4374`<style>` tags is not interpreted as Markdown.
4376This departure from standard Markdown should make it easier to mix
4377Markdown with HTML block elements. For example, one can surround
4378a block of Markdown text with `<div>` tags without preventing it
4379from being interpreted as Markdown.
4381#### Extension: `native_divs` ####
4383Use native pandoc `Div` blocks for content inside `<div>` tags.
4384For the most part this should give the same output as
4385`markdown_in_html_blocks`, but it makes it easier to write pandoc
4386filters to manipulate groups of blocks.
4388#### Extension: `native_spans` ####
4390Use native pandoc `Span` blocks for content inside `<span>` tags.
4391For the most part this should give the same output as `raw_html`,
4392but it makes it easier to write pandoc filters to manipulate groups
4393of inlines.
4395#### Extension: `raw_tex` ####
4397In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be
4398included in a document. Inline TeX commands will be preserved and passed
4399unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use
4400LaTeX to include BibTeX citations:
4402 This result was proved in \cite{jones.1967}.
4404Note that in LaTeX environments, like
4406 \begin{tabular}{|l|l|}\hline
4407 Age & Frequency \\ \hline
4408 18--25 & 15 \\
4409 26--35 & 33 \\
4410 36--45 & 22 \\ \hline
4411 \end{tabular}
4413the material between the begin and end tags will be interpreted as raw
4414LaTeX, not as Markdown.
4416For a more explicit and flexible way of including raw TeX in a
4417Markdown document, see the [`raw_attribute`
4418extension][Extension: `raw_attribute`].
4420Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
4421Emacs Org mode, and ConTeXt.
4423### Generic raw attribute ###
4425#### Extension: `raw_attribute` ####
4427Inline spans and fenced code blocks with a special
4428kind of attribute will be parsed as raw content with the
4429designated format. For example, the following produces a raw
4430roff `ms` block:
4432 ```{=ms}
4433 .MYMACRO
4434 blah blah
4435 ```
4436And the following produces a raw `html` inline element:
4438 This is `<a>html</a>`{=html}
4440This can be useful to insert raw xml into `docx` documents, e.g.
4441a pagebreak:
4443 ```{=openxml}
4444 <w:p>
4445 <w:r>
4446 <w:br w:type="page"/>
4447 </w:r>
4448 </w:p>
4449 ```
4451The format name should match the target format name (see
4452`-t/--to`, above, for a list, or use `pandoc
4453--list-output-formats`). Use `openxml` for `docx` output,
4454`opendocument` for `odt` output, `html5` for `epub3` output,
4455`html4` for `epub2` output, and `latex`, `beamer`,
4456`ms`, or `html5` for `pdf` output (depending on what you
4457use for `--pdf-engine`).
4459This extension presupposes that the relevant kind of
4460inline code or fenced code block is enabled. Thus, for
4461example, to use a raw attribute with a backtick code block,
4462`backtick_code_blocks` must be enabled.
4464The raw attribute cannot be combined with regular attributes.
4466## LaTeX macros
4468#### Extension: `latex_macros` ####
4470When this extension is enabled, pandoc will parse LaTeX
4471macro definitions and apply the resulting macros to all LaTeX
4472math and raw LaTeX. So, for example, the following will work in
4473all output formats, not just LaTeX:
4475 \newcommand{\tuple}[1]{\langle #1 \rangle}
4477 $\tuple{a, b, c}$
4479Note that LaTeX macros will not be applied if they occur
4480inside a raw span or block marked with the
4481[`raw_attribute` extension](#extension-raw_attribute).
4483When `latex_macros` is disabled, the raw LaTeX and math will
4484not have macros applied. This is usually a better approach when
4485you are targeting LaTeX or PDF.
4487Macro definitions in LaTeX will be passed through as raw LaTeX
4488only if `latex_macros` is not enabled. Macro definitions in
4489Markdown source (or other formats allowing `raw_tex`) will
4490be passed through regardless of whether `latex_macros` is
4491enabled.
4493## Links
4495Markdown allows links to be specified in several ways.
4497### Automatic links ###
4499If you enclose a URL or email address in pointy brackets, it
4500will become a link:
4502 <https://google.com>
4503 <sam@green.eggs.ham>
4505### Inline links ###
4507An inline link consists of the link text in square brackets,
4508followed by the URL in parentheses. (Optionally, the URL can
4509be followed by a link title, in quotes.)
4511 This is an [inline link](/url), and here's [one with
4512 a title](https://fsf.org "click here for a good time!").
4514There can be no space between the bracketed part and the parenthesized part.
4515The link text can contain formatting (such as emphasis), but the title cannot.
4517Email addresses in inline links are not autodetected, so they have to be
4518prefixed with `mailto`:
4520 [Write me!](mailto:sam@green.eggs.ham)
4522### Reference links ###
4524An *explicit* reference link has two parts, the link itself and the link
4525definition, which may occur elsewhere in the document (either
4526before or after the link).
4528The link consists of link text in square brackets, followed by a label in
4529square brackets. (There cannot be space between the two unless the
4530`spaced_reference_links` extension is enabled.) The link definition
4531consists of the bracketed label, followed by a colon and a space, followed by
4532the URL, and optionally (after a space) a link title either in quotes or in
4533parentheses. The label must not be parseable as a citation (assuming
4534the `citations` extension is enabled): citations take precedence over
4535link labels.
4537Here are some examples:
4539 [my label 1]: /foo/bar.html "My title, optional"
4540 [my label 2]: /foo
4541 [my label 3]: https://fsf.org (The free software foundation)
4542 [my label 4]: /bar#special 'A title in single quotes'
4544The URL may optionally be surrounded by angle brackets:
4546 [my label 5]: <http://foo.bar.baz>
4548The title may go on the next line:
4550 [my label 3]: https://fsf.org
4551 "The free software foundation"
4553Note that link labels are not case sensitive. So, this will work:
4555 Here is [my link][FOO]
4557 [Foo]: /bar/baz
4559In an *implicit* reference link, the second pair of brackets is
4560empty:
4562 See [my website][].
4564 [my website]: http://foo.bar.baz
4566Note: In `Markdown.pl` and most other Markdown implementations,
4567reference link definitions cannot occur in nested constructions
4568such as list items or block quotes. Pandoc lifts this arbitrary
4569seeming restriction. So the following is fine in pandoc, though
4570not in most other implementations:
4572 > My block [quote].
4574 > [quote]: /foo
4576#### Extension: `shortcut_reference_links` ####
4578In a *shortcut* reference link, the second pair of brackets may
4579be omitted entirely:
4581 See [my website].
4583 [my website]: http://foo.bar.baz
4585### Internal links ###
4587To link to another section of the same document, use the automatically
4588generated identifier (see [Heading identifiers]). For example:
4590 See the [Introduction](#introduction).
4594 See the [Introduction].
4596 [Introduction]: #introduction
4598Internal links are currently supported for HTML formats (including
4599HTML slide shows and EPUB), LaTeX, and ConTeXt.
4601## Images
4603A link immediately preceded by a `!` will be treated as an image.
4604The link text will be used as the image's alt text:
4606 ![la lune](lalune.jpg "Voyage to the moon")
4608 ![movie reel]
4610 [movie reel]: movie.gif
4612#### Extension: `implicit_figures` ####
4614An image with nonempty alt text, occurring by itself in a
4615paragraph, will be rendered as a figure with a caption. The
4616image's alt text will be used as the caption.
4618 ![This is the caption](/url/of/image.png)
4620How this is rendered depends on the output format. Some output
4621formats (e.g. RTF) do not yet support figures. In those
4622formats, you'll just get an image in a paragraph by itself, with
4623no caption.
4625If you just want a regular inline image, just make sure it is not
4626the only thing in the paragraph. One way to do this is to insert a
4627nonbreaking space after the image:
4629 ![This image won't be a figure](/url/of/image.png)\
4631Note that in reveal.js slide shows, an image in a paragraph
4632by itself that has the `stretch` class will fill the screen,
4633and the caption and figure tags will be omitted.
4635#### Extension: `link_attributes` ####
4637Attributes can be set on links and images:
4639 An inline ![image](foo.jpg){#id .class width=30 height=20px}
4640 and a reference ![image][ref] with attributes.
4642 [ref]: foo.jpg "optional title" {#id .class key=val key2="val 2"}
4644(This syntax is compatible with [PHP Markdown Extra] when only `#id`
4645and `.class` are used.)
4647For HTML and EPUB, all known HTML5 attributes except `width` and
4648`height` (but including `srcset` and `sizes`) are passed through
4649as is. Unknown attributes are passed through as custom
4650attributes, with `data-` prepended. The other writers ignore
4651attributes that are not specifically supported by their output format.
4653The `width` and `height` attributes on images are treated specially. When
4654used without a unit, the unit is assumed to be pixels. However, any of
4655the following unit identifiers can be used: `px`, `cm`, `mm`, `in`, `inch`
4656and `%`. There must not be any spaces between the number and the unit.
4657For example:
4659```
4660![](file.jpg){ width=50% }
4661```
4663- Dimensions may be converted to a form that is compatible with
4664 the output format (for example, dimensions given in pixels will
4665 be converted to inches when converting HTML to LaTeX). Conversion
4666 between pixels and physical measurements is affected by the
4667 `--dpi` option (by default, 96 dpi is assumed, unless the image
4668 itself contains dpi information).
4669- The `%` unit is generally relative to some available space.
4670 For example the above example will render to the following.
4671 - HTML: `<img href="file.jpg" style="width: 50%;" />`
4672 - LaTeX: `\includegraphics[width=0.5\textwidth,height=\textheight]{file.jpg}`
4673 (If you're using a custom template, you need to configure `graphicx`
4674 as in the default template.)
4675 - ConTeXt: `\externalfigure[file.jpg][width=0.5\textwidth]`
4676- Some output formats have a notion of a class
4677 ([ConTeXt](https://wiki.contextgarden.net/Using_Graphics#Multiple_Image_Settings))
4678 or a unique identifier (LaTeX `\caption`), or both (HTML).
4679- When no `width` or `height` attributes are specified, the fallback
4680 is to look at the image resolution and the dpi metadata embedded in
4681 the image file.
4683## Divs and Spans
4685Using the `native_divs` and `native_spans` extensions
4686(see [above][Extension: `native_divs`]), HTML syntax can
4687be used as part of markdown to create native `Div` and `Span`
4688elements in the pandoc AST (as opposed to raw HTML).
4689However, there is also nicer syntax available:
4691#### Extension: `fenced_divs` ####
4693Allow special fenced syntax for native `Div` blocks. A Div
4694starts with a fence containing at least three consecutive
4695colons plus some attributes. The attributes may optionally
4696be followed by another string of consecutive colons.
4697The attribute syntax is exactly as in fenced code blocks (see
4698[Extension: `fenced_code_attributes`]). As with fenced
4699code blocks, one can use either attributes in curly braces
4700or a single unbraced word, which will be treated as a class
4701name. The Div ends with another line containing a string of at
4702least three consecutive colons. The fenced Div should be
4703separated by blank lines from preceding and following blocks.
4705Example:
4707 ::::: {#special .sidebar}
4708 Here is a paragraph.
4710 And another.
4711 :::::
4713Fenced divs can be nested. Opening fences are distinguished
4714because they *must* have attributes:
4716 ::: Warning ::::::
4717 This is a warning.
4719 ::: Danger
4720 This is a warning within a warning.
4721 :::
4722 ::::::::::::::::::
4724Fences without attributes are always closing fences. Unlike
4725with fenced code blocks, the number of colons in the closing
4726fence need not match the number in the opening fence. However,
4727it can be helpful for visual clarity to use fences of different
4728lengths to distinguish nested divs from their parents.
4731#### Extension: `bracketed_spans` ####
4733A bracketed sequence of inlines, as one would use to begin
4734a link, will be treated as a `Span` with attributes if it is
4735followed immediately by attributes:
4737 [This is *some text*]{.class key="val"}
4739## Footnotes
4741#### Extension: `footnotes` ####
4743Pandoc's Markdown allows footnotes, using the following syntax:
4745 Here is a footnote reference,[^1] and another.[^longnote]
4747 [^1]: Here is the footnote.
4749 [^longnote]: Here's one with multiple blocks.
4751 Subsequent paragraphs are indented to show that they
4752 belong to the previous footnote.
4754 { some.code }
4756 The whole paragraph can be indented, or just the first
4757 line. In this way, multi-paragraph footnotes work like
4758 multi-paragraph list items.
4760 This paragraph won't be part of the note, because it
4761 isn't indented.
4763The identifiers in footnote references may not contain spaces, tabs,
4764or newlines. These identifiers are used only to correlate the
4765footnote reference with the note itself; in the output, footnotes
4766will be numbered sequentially.
4768The footnotes themselves need not be placed at the end of the
4769document. They may appear anywhere except inside other block elements
4770(lists, block quotes, tables, etc.). Each footnote should be
4771separated from surrounding content (including other footnotes)
4772by blank lines.
4774#### Extension: `inline_notes` ####
4776Inline footnotes are also allowed (though, unlike regular notes,
4777they cannot contain multiple paragraphs). The syntax is as follows:
4779 Here is an inline note.^[Inlines notes are easier to write, since
4780 you don't have to pick an identifier and move down to type the
4781 note.]
4783Inline and regular footnotes may be mixed freely.
4785## Citation syntax
4787#### Extension: `citations` ####
4789Markdown citations go inside square brackets and are separated
4790by semicolons. Each citation must have a key, composed of '@' +
4791the citation identifier from the database, and may optionally
4792have a prefix, a locator, and a suffix. The citation key must
4793begin with a letter, digit, or `_`, and may contain
4794alphanumerics, `_`, and internal punctuation characters
4795(`:.#$%&-+?<>~/`). Here are some examples:
4797 Blah blah [see @doe99, pp. 33-35; also @smith04, chap. 1].
4799 Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].
4801 Blah blah [@smith04; @doe99].
4803`pandoc` detects locator terms in the [CSL locale files].
4804Either abbreviated or unabbreviated forms are accepted. In the `en-US`
4805locale, locator terms can be written in either singular or plural forms,
4806as `book`, `bk.`/`bks.`; `chapter`, `chap.`/`chaps.`; `column`,
4807`col.`/`cols.`; `figure`, `fig.`/`figs.`; `folio`, `fol.`/`fols.`;
4808`number`, `no.`/`nos.`; `line`, `l.`/`ll.`; `note`, `n.`/`nn.`; `opus`,
4809`op.`/`opp.`; `page`, `p.`/`pp.`; `paragraph`, `para.`/`paras.`; `part`,
4810`pt.`/`pts.`; `section`, `sec.`/`secs.`; `sub verbo`, `s.v.`/`s.vv.`;
4811`verse`, `v.`/`vv.`; `volume`, `vol.`/`vols.`; `¶`/`¶¶`; `§`/`§§`. If no
4812locator term is used, "page" is assumed.
4814`pandoc` will use heuristics to distinguish the locator
4815from the suffix. In complex cases, the locator can be enclosed
4816in curly braces:
4818 [@smith{ii, A, D-Z}, with a suffix]
4819 [@smith, {pp. iv, vi-xi, (xv)-(xvii)} with suffix here]
4821A minus sign (`-`) before the `@` will suppress mention of
4822the author in the citation. This can be useful when the
4823author is already mentioned in the text:
4825 Smith says blah [-@smith04].
4827You can also write an in-text citation, as follows:
4829 @smith04 says blah.
4831 @smith04 [p. 33] says blah.
4834[CSL]: https://docs.citationstyles.org/en/stable/specification.html
4835[CSL markup specs]: https://docs.citationstyles.org/en/1.0/release-notes.html#rich-text-markup-within-fields
4836[Chicago Manual of Style]: https://chicagomanualofstyle.org
4837[Citation Style Language]: https://citationstyles.org
4838[Zotero Style Repository]: https://www.zotero.org/styles
4839[finding and editing styles]: https://citationstyles.org/authors/
4840[CSL locale files]: https://github.com/citation-style-language/locales
4842## Non-pandoc extensions
4844The following Markdown syntax extensions are not enabled by default
4845in pandoc, but may be enabled by adding `+EXTENSION` to the format
4846name, where `EXTENSION` is the name of the extension. Thus, for
4847example, `markdown+hard_line_breaks` is Markdown with hard line breaks.
4849#### Extension: `attributes` ####
4851Allows attributes to be attached to any inline or block-level
4852element. The syntax for the attributes is the same as that
4853used in [`header_attributes`][Extension: `header_attributes`].
4855- Attributes that occur immediately after an inline
4856 element affect that element. If they follow a space, then they
4857 belong to the space. (Hence, this option subsumes
4858 `inline_code_attributes` and `link_attributes`.)
4859- Attributes that occur immediately before a block
4860 element, on a line by themselves, affect that
4861 element.
4862- Consecutive attribute specifiers may be used,
4863 either for blocks or for inlines. Their attributes
4864 will be combined.
4865- Attributes that occur at the end of the text of
4866 a Setext or ATX heading (separated by whitespace
4867 from the text) affect the heading element. (Hence, this
4868 option subsumes `header_attributes`.)
4869- Attributes that occur after the opening fence
4870 in a fenced code block affect the code block element. (Hence,
4871 this option subsumes `fenced_code_attributes`.)
4872- Attributes that occur at the end of a reference
4873 link definition affect links that refer to that
4874 definition.
4876Note that pandoc's AST does not currently allow attributes
4877to be attached to arbitrary elements. Hence a Span or Div
4878container will be added if needed.
4880#### Extension: `old_dashes` ####
4882Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:
4883`-` before a numeral is an en-dash, and `--` is an em-dash.
4884This option only has an effect if `smart` is enabled. It is
4885selected automatically for `textile` input.
4887#### Extension: `angle_brackets_escapable` ####
4889Allow `<` and `>` to be backslash-escaped, as they can be in
4890GitHub flavored Markdown but not original Markdown. This is
4891implied by pandoc's default `all_symbols_escapable`.
4893#### Extension: `lists_without_preceding_blankline` ####
4895Allow a list to occur right after a paragraph, with no intervening
4896blank space.
4898#### Extension: `four_space_rule` ####
4900Selects the pandoc <= 2.0 behavior for parsing lists, so that
4901four spaces indent are needed for list item continuation
4902paragraphs.
4904#### Extension: `spaced_reference_links` ####
4906Allow whitespace between the two components of a reference link,
4907for example,
4909 [foo] [bar].
4911#### Extension: `hard_line_breaks` ####
4913Causes all newlines within a paragraph to be interpreted as hard line
4914breaks instead of spaces.
4916#### Extension: `ignore_line_breaks` ####
4918Causes newlines within a paragraph to be ignored, rather than being
4919treated as spaces or as hard line breaks. This option is intended for
4920use with East Asian languages where spaces are not used between words,
4921but text is divided into lines for readability.
4923#### Extension: `east_asian_line_breaks` ####
4925Causes newlines within a paragraph to be ignored, rather than
4926being treated as spaces or as hard line breaks, when they occur
4927between two East Asian wide characters. This is a better choice
4928than `ignore_line_breaks` for texts that include a mix of East
4929Asian wide characters and other characters.
4931#### Extension: `emoji` ####
4933Parses textual emojis like `:smile:` as Unicode emoticons.
4935#### Extension: `tex_math_single_backslash` ####
4937Causes anything between `\(` and `\)` to be interpreted as inline
4938TeX math, and anything between `\[` and `\]` to be interpreted
4939as display TeX math. Note: a drawback of this extension is that
4940it precludes escaping `(` and `[`.
4942#### Extension: `tex_math_double_backslash` ####
4944Causes anything between `\\(` and `\\)` to be interpreted as inline
4945TeX math, and anything between `\\[` and `\\]` to be interpreted
4946as display TeX math.
4948#### Extension: `markdown_attribute` ####
4950By default, pandoc interprets material inside block-level tags as Markdown.
4951This extension changes the behavior so that Markdown is only parsed
4952inside block-level tags if the tags have the attribute `markdown=1`.
4954#### Extension: `mmd_title_block` ####
4956Enables a [MultiMarkdown] style title block at the top of
4957the document, for example:
4959 Title: My title
4960 Author: John Doe
4961 Date: September 1, 2008
4962 Comment: This is a sample mmd title block, with
4963 a field spanning multiple lines.
4965See the MultiMarkdown documentation for details. If `pandoc_title_block` or
4966`yaml_metadata_block` is enabled, it will take precedence over
4967`mmd_title_block`.
4969#### Extension: `abbreviations` ####
4971Parses PHP Markdown Extra abbreviation keys, like
4973 *[HTML]: Hypertext Markup Language
4975Note that the pandoc document model does not support
4976abbreviations, so if this extension is enabled, abbreviation keys are
4977simply skipped (as opposed to being parsed as paragraphs).
4979#### Extension: `autolink_bare_uris` ####
4981Makes all absolute URIs into links, even when not surrounded by
4982pointy braces `<...>`.
4984#### Extension: `mmd_link_attributes` ####
4986Parses multimarkdown style key-value attributes on link
4987and image references. This extension should not be confused with the
4988[`link_attributes`](#extension-link_attributes) extension.
4990 This is a reference ![image][ref] with multimarkdown attributes.
4992 [ref]: https://path.to/image "Image title" width=20px height=30px
4993 id=myId class="myClass1 myClass2"
4995#### Extension: `mmd_header_identifiers` ####
4997Parses multimarkdown style heading identifiers (in square brackets,
4998after the heading but before any trailing `#`s in an ATX heading).
5000#### Extension: `compact_definition_lists` ####
5002Activates the definition list syntax of pandoc 1.12.x and earlier.
5003This syntax differs from the one described above under [Definition lists]
5004in several respects:
5006 - No blank line is required between consecutive items of the
5007 definition list.
5008 - To get a "tight" or "compact" list, omit space between consecutive
5009 items; the space between a term and its definition does not affect
5010 anything.
5011 - Lazy wrapping of paragraphs is not allowed: the entire definition must
5012 be indented four spaces.[^6]
5014[^6]: To see why laziness is incompatible with relaxing the requirement
5015 of a blank line between items, consider the following example:
5017 bar
5018 : definition
5019 foo
5020 : definition
5022 Is this a single list item with two definitions of "bar," the first of
5023 which is lazily wrapped, or two list items? To remove the ambiguity
5024 we must either disallow lazy wrapping or require a blank line between
5025 list items.
5027#### Extension: `gutenberg` ####
5029Use [Project Gutenberg] conventions for `plain` output:
5030all-caps for strong emphasis, surround by underscores
5031for regular emphasis, add extra blank space around headings.
5033 [Project Gutenberg]: https://www.gutenberg.org
5035## Markdown variants
5037In addition to pandoc's extended Markdown, the following Markdown
5038variants are supported:
5040- `markdown_phpextra` (PHP Markdown Extra)
5041- `markdown_github` (deprecated GitHub-Flavored Markdown)
5042- `markdown_mmd` (MultiMarkdown)
5043- `markdown_strict` (Markdown.pl)
5044- `commonmark` (CommonMark)
5045- `gfm` (Github-Flavored Markdown)
5046- `commonmark_x` (CommonMark with many pandoc extensions)
5048To see which extensions are supported for a given format,
5049and which are enabled by default, you can use the command
5051 pandoc --list-extensions=FORMAT
5053where `FORMAT` is replaced with the name of the format.
5055Note that the list of extensions for `commonmark`,
5056`gfm`, and `commonmark_x` are defined relative to default
5057commonmark. So, for example, `backtick_code_blocks`
5058does not appear as an extension, since it is enabled by
5059default and cannot be disabled.
5061# Citations
5063When the `--citeproc` option is used, pandoc can automatically generate
5064citations and a bibliography in a number of styles. Basic usage is
5066 pandoc --citeproc myinput.txt
5068To use this feature, you will need to have
5070- a document containing citations (see [Extension: `citations`]);
5071- a source of bibliographic data: either an external bibliography
5072 file or a list of `references` in the document's YAML metadata
5073- optionally, a [CSL] citation style.
5075## Specifying bibliographic data
5077You can specify an external bibliography using the
5078`bibliography` metadata field in a YAML metadata section or the
5079`--bibliography` command line argument. If you want to use
5080multiple bibliography files, you can supply multiple
5081`--bibliography` arguments or set `bibliography` metadata field
5082to YAML array. A bibliography may have any of these formats:
5084 Format File extension
5085 ------------ --------------
5086 BibLaTeX .bib
5087 BibTeX .bibtex
5088 CSL JSON .json
5089 CSL YAML .yaml
5091Note that `.bib` can be used with both BibTeX and BibLaTeX files;
5092use the extension `.bibtex` to force interpretation as BibTeX.
5094In BibTeX and BibLaTeX databases, pandoc parses LaTeX markup
5095inside fields such as `title`; in CSL YAML databases, pandoc
5096Markdown; and in CSL JSON databases, an [HTML-like markup][CSL
5097markup specs]:
5099`<i>...</i>`
5100: italics
5102`<b>...</b>`
5103: bold
5105`<span style="font-variant:small-caps;">...</span>` or `<sc>...</sc>`
5106: small capitals
5108`<sub>...</sub>`
5109: subscript
5111`<sup>...</sup>`
5112: superscript
5114`<span class="nocase">...</span>`
5115: prevent a phrase from being capitalized as title case
5117As an alternative to specifying a bibliography file using
5118`--bibliography` or the YAML metadata field `bibliography`, you
5119can include the citation data directly in the `references` field
5120of the document's YAML metadata. The field should contain an
5121array of YAML-encoded references, for example:
5123 ---
5124 references:
5125 - type: article-journal
5126 id: WatsonCrick1953
5127 author:
5128 - family: Watson
5129 given: J. D.
5130 - family: Crick
5131 given: F. H. C.
5132 issued:
5133 date-parts:
5134 - - 1953
5135 - 4
5136 - 25
5137 title: 'Molecular structure of nucleic acids: a structure for
5138 deoxyribose nucleic acid'
5139 title-short: Molecular structure of nucleic acids
5140 container-title: Nature
5141 volume: 171
5142 issue: 4356
5143 page: 737-738
5144 DOI: 10.1038/171737a0
5145 URL: https://www.nature.com/articles/171737a0
5146 language: en-GB
5147 ...
5149Note that `pandoc` can be used to produce such a YAML metadata
5150section from a BibTeX, BibLaTeX, or CSL JSON bibliography:
5152 pandoc chem.bib -s -f biblatex -t markdown
5153 pandoc chem.json -s -f csljson -t markdown
5155`pandoc` can also be used to produce CSL JSON bibliography
5156from BibTeX, BibLaTeX, or markdown YAML:
5158 pandoc chem.bib -s -f biblatex -t csljson
5159 pandoc chem.yaml -s -f markdown -t csljson
5161Running pandoc on a bibliography file with the `--citeproc`
5162option will create a formatted bibliography in the format
5163of your choice:
5165 pandoc chem.bib -s --citeproc -o chem.html
5166 pandoc chem.bib -s --citeproc -o chem.pdf
5168### Capitalization in titles
5170If you are using a bibtex or biblatex bibliography, then observe
5171the following rules:
5173 - English titles should be in title case. Non-English titles should
5174 be in sentence case, and the `langid` field in biblatex should be
5175 set to the relevant language. (The following values are treated
5176 as English: `american`, `british`, `canadian`, `english`,
5177 `australian`, `newzealand`, `USenglish`, or `UKenglish`.)
5179 - As is standard with bibtex/biblatex, proper names should be
5180 protected with curly braces so that they won't be lowercased
5181 in styles that call for sentence case. For example:
5183 title = {My Dinner with {Andre}}
5185 - In addition, words that should remain lowercase (or camelCase)
5186 should be protected:
5188 title = {Spin Wave Dispersion on the {nm} Scale}
5190 Though this is not necessary in bibtex/biblatex, it is necessary
5191 with citeproc, which stores titles internally in sentence case,
5192 and converts to title case in styles that require it. Here we
5193 protect "nm" so that it doesn't get converted to "Nm" at this stage.
5195If you are using a CSL bibliography (either JSON or YAML), then observe
5196the following rules:
5198 - All titles should be in sentence case.
5200 - Use the `language` field for non-English titles to prevent their
5201 conversion to title case in styles that call for this. (Conversion
5202 happens only if `language` begins with `en` or is left empty.)
5204 - Protect words that should not be converted to title case using
5205 this syntax:
5207 Spin wave dispersion on the <span class="nocase">nm</span> scale
5209### Conference Papers, Published vs. Unpublished
5211For a formally published conference paper, use the biblatex entry type
5212`inproceedings` (which will be mapped to CSL `paper-conference`).
5214For an unpublished manuscript, use the biblatex entry type
5215`unpublished` without an `eventtitle` field (this entry type
5216will be mapped to CSL `manuscript`).
5218For a talk, an unpublished conference paper, or a poster
5219presentation, use the biblatex entry type `unpublished` with an
5220`eventtitle` field (this entry type will be mapped to CSL
5221`speech`). Use the biblatex `type` field to indicate the type,
5222e.g. "Paper", or "Poster". `venue` and `eventdate` may be useful
5223too, though `eventdate` will not be rendered by most CSL styles.
5224Note that `venue` is for the event's venue, unlike `location`
5225which describes the publisher's location; do not use the latter
5226for an unpublished conference paper.
5229## Specifying a citation style
5231Citations and references can be formatted using any style supported by the
5232[Citation Style Language], listed in the [Zotero Style Repository].
5233These files are specified using the `--csl` option or the `csl`
5234(or `citation-style`) metadata field. By default, pandoc will
5235use the [Chicago Manual of Style] author-date format. (You can
5236override this default by copying a CSL style of your choice
5237to `default.csl` in your user data directory.)
5238The CSL project provides further information on [finding and
5239editing styles].
5241The `--citation-abbreviations` option (or the
5242`citation-abbreviations` metadata field) may be used to
5243specify a JSON file containing abbreviations of journals
5244that should be used in formatted bibliographies when
5245`form="short"` is specified. The format of the file
5246can be illustrated with an example:
5249 { "default": {
5250 "container-title": {
5251 "Lloyd's Law Reports": "Lloyd's Rep",
5252 "Estates Gazette": "EG",
5253 "Scots Law Times": "SLT"
5258## Raw content in a style
5260To include raw content in a prefix, suffix, delimiter, or term,
5261surround it with these tags indicating the format:
5263 {{jats}}&lt;ref&gt;{{/jats}}
5265Without the tags, the string will be interpreted as a string
5266and escaped in the output, rather than being passed through raw.
5268This feature allows stylesheets to be customized to give
5269different output for different output formats. However,
5270stylesheets customized in this way will not be usable
5271by other CSL implementations.
5275## Placement of the bibliography
5277If the style calls for a list of works cited, it will be placed
5278in a div with id `refs`, if one exists:
5280 ::: {#refs}
5281 :::
5283Otherwise, it will be placed at the end of the document.
5284Generation of the bibliography can be suppressed by setting
5285`suppress-bibliography: true` in the YAML metadata.
5287If you wish the bibliography to have a section heading, you can
5288set `reference-section-title` in the metadata, or put the heading
5289at the beginning of the div with id `refs` (if you are using it)
5290or at the end of your document:
5292 last paragraph...
5294 # References
5296The bibliography will be inserted after this heading. Note that
5297the `unnumbered` class will be added to this heading, so that the
5298section will not be numbered.
5300## Including uncited items in the bibliography
5302If you want to include items in the bibliography without actually
5303citing them in the body text, you can define a dummy `nocite` metadata
5304field and put the citations there:
5306 ---
5307 nocite: |
5308 @item1, @item2
5309 ...
5311 @item3
5313In this example, the document will contain a citation for `item3`
5314only, but the bibliography will contain entries for `item1`, `item2`, and
5315`item3`.
5317It is possible to create a bibliography with all the citations,
5318whether or not they appear in the document, by using a wildcard:
5320 ---
5321 nocite: |
5322 @*
5323 ...
5325For LaTeX output, you can also use [`natbib`] or [`biblatex`] to
5326render the bibliography. In order to do so, specify bibliography
5327files as outlined above, and add `--natbib` or `--biblatex`
5328argument to `pandoc` invocation. Bear in mind that bibliography
5329files have to be in either BibTeX (for `--natbib`)
5330or BibLaTeX (for `--biblatex`) format.
5332## Other relevant metadata fields
5334A few other metadata fields affect bibliography formatting:
5336`link-citation`
5337: If true, citations will be
5338 hyperlinked to the corresponding bibliography entries
5339 (for author-date and numerical styles only).
5341`lang`
5342: The `lang` field will affect how the style is localized,
5343 for example in the translation of labels and the use
5344 of quotation marks. (For backwards compatibility,
5345 `locale` may be used instead of `lang`, but this use
5346 is deprecated.)
5348`notes-after-punctuation`
5349: If true (the default), pandoc will put footnote citations
5350 after following punctuation. For example, if the source
5351 contains `blah blah [@jones99].`, the result will look like
5352 `blah blah.[^1]`, with the note moved after the period and
5353 the space collapsed. If false, the space will still be
5354 collapsed, but the footnote will not be moved after the
5355 punctuation.
5364# Slide shows
5366You can use pandoc to produce an HTML + JavaScript slide presentation
5367that can be viewed via a web browser. There are five ways to do this,
5368using [S5], [DZSlides], [Slidy], [Slideous], or [reveal.js].
5369You can also produce a PDF slide show using LaTeX [`beamer`], or
5370slides shows in Microsoft [PowerPoint] format.
5372Here's the Markdown source for a simple slide show, `habits.txt`:
5374 % Habits
5375 % John Doe
5376 % March 22, 2005
5378 # In the morning
5380 ## Getting up
5382 - Turn off alarm
5383 - Get out of bed
5385 ## Breakfast
5387 - Eat eggs
5388 - Drink coffee
5390 # In the evening
5392 ## Dinner
5394 - Eat spaghetti
5395 - Drink wine
5397 ------------------
5399 ![picture of spaghetti](images/spaghetti.jpg)
5401 ## Going to sleep
5403 - Get in bed
5404 - Count sheep
5406To produce an HTML/JavaScript slide show, simply type
5408 pandoc -t FORMAT -s habits.txt -o habits.html
5410where `FORMAT` is either `s5`, `slidy`, `slideous`, `dzslides`, or `revealjs`.
5412For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with the
5413`-s/--standalone` option embeds a link to JavaScript and CSS files, which are
5414assumed to be available at the relative path `s5/default` (for S5), `slideous`
5415(for Slideous), `reveal.js` (for reveal.js), or at the Slidy website at
5416`w3.org` (for Slidy). (These paths can be changed by setting the `slidy-url`,
5417`slideous-url`, `revealjs-url`, or `s5-url` variables; see [Variables for HTML slides],
5418above.) For DZSlides, the (relatively short) JavaScript and CSS are included in
5419the file by default.
5421With all HTML slide formats, the `--self-contained` option can be used to
5422produce a single file that contains all of the data necessary to display the
5423slide show, including linked scripts, stylesheets, images, and videos.
5425To produce a PDF slide show using beamer, type
5427 pandoc -t beamer habits.txt -o habits.pdf
5429Note that a reveal.js slide show can also be converted to a PDF
5430by printing it to a file from the browser.
5432To produce a Powerpoint slide show, type
5434 pandoc habits.txt -o habits.pptx
5436## Structuring the slide show
5438By default, the *slide level* is the highest heading level in
5439the hierarchy that is followed immediately by content, and not another
5440heading, somewhere in the document. In the example above, level-1 headings
5441are always followed by level-2 headings, which are followed by content,
5442so the slide level is 2. This default can be overridden using
5443the `--slide-level` option.
5445The document is carved up into slides according to the following
5446rules:
5448 * A horizontal rule always starts a new slide.
5450 * A heading at the slide level always starts a new slide.
5452 * Headings *below* the slide level in the hierarchy create
5453 headings *within* a slide.
5455 * Headings *above* the slide level in the hierarchy create
5456 "title slides," which just contain the section title
5457 and help to break the slide show into sections.
5458 Non-slide content under these headings will be included
5459 on the title slide (for HTML slide shows) or in a
5460 subsequent slide with the same title (for beamer).
5462 * A title page is constructed automatically from the document's title
5463 block, if present. (In the case of beamer, this can be disabled
5464 by commenting out some lines in the default template.)
5466These rules are designed to support many different styles of slide show. If
5467you don't care about structuring your slides into sections and subsections,
5468you can just use level-1 headings for all each slide. (In that case, level-1
5469will be the slide level.) But you can also structure the slide show into
5470sections, as in the example above.
5472Note: in reveal.js slide shows, if slide level is 2, a two-dimensional
5473layout will be produced, with level-1 headings building horizontally
5474and level-2 headings building vertically. It is not recommended that
5475you use deeper nesting of section levels with reveal.js.
5477## Incremental lists
5479By default, these writers produce lists that display "all at once."
5480If you want your lists to display incrementally (one item at a time),
5481use the `-i` option. If you want a particular list to depart from the
5482default, put it in a `div` block with class `incremental` or
5483`nonincremental`. So, for example, using the `fenced div` syntax, the
5484following would be incremental regardless of the document default:
5486 ::: incremental
5488 - Eat spaghetti
5489 - Drink wine
5491 :::
5495 ::: nonincremental
5497 - Eat spaghetti
5498 - Drink wine
5500 :::
5502While using `incremental` and `nonincremental` divs are the
5503recommended method of setting incremental lists on a per-case basis,
5504an older method is also supported: putting lists inside a blockquote
5505will depart from the document default (that is, it will display
5506incrementally without the `-i` option and all at once with the `-i`
5507option):
5509 > - Eat spaghetti
5510 > - Drink wine
5512Both methods allow incremental and nonincremental lists to be mixed
5513in a single document.
5515Note: Neither the `-i/--incremental` option nor any of the
5516methods described here currently works for PowerPoint output.
5518## Inserting pauses
5520You can add "pauses" within a slide by including a paragraph containing
5521three dots, separated by spaces:
5523 # Slide with a pause
5525 content before the pause
5527 . . .
5529 content after the pause
5531Note: this feature is not yet implemented for PowerPoint output.
5533## Styling the slides
5535You can change the style of HTML slides by putting customized CSS files
5536in `$DATADIR/s5/default` (for S5), `$DATADIR/slidy` (for Slidy),
5537or `$DATADIR/slideous` (for Slideous),
5538where `$DATADIR` is the user data directory (see `--data-dir`, above).
5539The originals may be found in pandoc's system data directory (generally
5540`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any
5541files it does not find in the user data directory.
5543For dzslides, the CSS is included in the HTML file itself, and may
5544be modified there.
5546All [reveal.js configuration options] can be set through variables.
5547For example, themes can be used by setting the `theme` variable:
5549 -V theme=moon
5551Or you can specify a custom stylesheet using the `--css` option.
5553To style beamer slides, you can specify a `theme`, `colortheme`,
5554`fonttheme`, `innertheme`, and `outertheme`, using the `-V` option:
5556 pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf
5558Note that heading attributes will turn into slide attributes
5559(on a `<div>` or `<section>`) in HTML slide formats, allowing you
5560to style individual slides. In beamer, the only heading attribute
5561that affects slides is the `allowframebreaks` class, which sets the
5562`allowframebreaks` option, causing multiple slides to be created
5563if the content overfills the frame. This is recommended especially for
5564bibliographies:
5566 # References {.allowframebreaks}
5568## Speaker notes
5570Speaker notes are supported in reveal.js and PowerPoint (pptx)
5571output. You can add notes to your Markdown document thus:
5573 ::: notes
5575 This is my note.
5577 - It can contain Markdown
5578 - like this list
5580 :::
5582To show the notes window in reveal.js, press `s` while viewing the
5583presentation. Speaker notes in PowerPoint will be available, as usual,
5584in handouts and presenter view.
5586Notes are not yet supported for other slide formats, but the notes
5587will not appear on the slides themselves.
5589## Columns
5591To put material in side by side columns, you can use a native
5592div container with class `columns`, containing two or more div
5593containers with class `column` and a `width` attribute:
5595 :::::::::::::: {.columns}
5596 ::: {.column width="40%"}
5597 contents...
5598 :::
5599 ::: {.column width="60%"}
5600 contents...
5601 :::
5602 ::::::::::::::
5604### Additional columns attributes in beamer
5606The div containers with classes `columns` and `column` can optionally have
5607an `align` attribute.
5608The class `columns` can optionally have a `totalwidth` attribute or an
5609`onlytextwidth` class.
5611 :::::::::::::: {.columns align=center totalwidth=8em}
5612 ::: {.column width="40%"}
5613 contents...
5614 :::
5615 ::: {.column width="60%" align=bottom}
5616 contents...
5617 :::
5618 ::::::::::::::
5620The `align` attributes on `columns` and `column` can be used with the
5621values `top`, `top-baseline`, `center` and `bottom` to vertically align
5622the columns. It defaults to `top` in `columns`.
5624The `totalwidth` attribute limits the width of the columns to the given value.
5626 :::::::::::::: {.columns align=top .onlytextwidth}
5627 ::: {.column width="40%" align=center}
5628 contents...
5629 :::
5630 ::: {.column width="60%"}
5631 contents...
5632 :::
5633 ::::::::::::::
5635The class `onlytextwidth` sets the `totalwidth` to `\textwidth`.
5637See Section 12.7 of the [Beamer User's Guide] for more details.
5639## Frame attributes in beamer
5641Sometimes it is necessary to add the LaTeX `[fragile]` option to
5642a frame in beamer (for example, when using the `minted` environment).
5643This can be forced by adding the `fragile` class to the heading
5644introducing the slide:
5646 # Fragile slide {.fragile}
5648All of the other frame attributes described in Section 8.1 of
5649the [Beamer User's Guide] may also be used: `allowdisplaybreaks`,
5650`allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`,
5651`shrink`, `standout`, `noframenumbering`.
5653## Background in reveal.js and beamer
5655Background images can be added to self-contained reveal.js slideshows and
5656to beamer slideshows.
5658For the same image on every slide, use the configuration
5659option `background-image` either in the YAML metadata block
5660or as a command-line variable. (There are no other options in
5661beamer and the rest of this section concerns reveal.js slideshows.)
5663For reveal.js, you can instead use the reveal.js-native option
5664`parallaxBackgroundImage`. You can also set `parallaxBackgroundHorizontal`
5665and `parallaxBackgroundVertical` the same way and must also set
5666`parallaxBackgroundSize` to have your values take effect.
5668To set an image for a particular reveal.js slide, add
5669`{data-background-image="/path/to/image"}`
5670to the first slide-level heading on the slide (which may even be empty).
5672In reveal.js's overview mode, the parallaxBackgroundImage will show up
5673only on the first slide.
5675Other reveal.js background settings also work on individual slides, including
5676`data-background-size`, `data-background-repeat`, `data-background-color`,
5677`data-transition`, and `data-transition-speed`.
5679To add a background image to the automatically generated title slide, use the
5680`title-slide-attributes` variable in the YAML metadata block. It must contain
5681a map of attribute names and values.
5683See the [reveal.js documentation](https://revealjs.com/backgrounds/) for more
5684details.
5686For example in reveal.js:
5688```
5689---
5690title: My Slideshow
5691parallaxBackgroundImage: /path/to/my/background_image.png
5692title-slide-attributes:
5693 data-background-image: /path/to/title_image.png
5694 data-background-size: contain
5695---
5697## Slide One
5699Slide 1 has background_image.png as its background.
5701## {data-background-image="/path/to/special_image.jpg"}
5703Slide 2 has a special image for its background, even though the heading has no content.
5704```
5706# EPUBs
5708## EPUB Metadata
5710EPUB metadata may be specified using the `--epub-metadata` option, but
5711if the source document is Markdown, it is better to use a [YAML metadata
5712block][Extension: `yaml_metadata_block`]. Here is an example:
5714 ---
5715 title:
5716 - type: main
5717 text: My Book
5718 - type: subtitle
5719 text: An investigation of metadata
5720 creator:
5721 - role: author
5722 text: John Smith
5723 - role: editor
5724 text: Sarah Jones
5725 identifier:
5726 - scheme: DOI
5727 text: doi:10.234234.234/33
5728 publisher: My Press
5729 rights: © 2007 John Smith, CC BY-NC
5730 ibooks:
5731 version: 1.3.4
5732 ...
5734The following fields are recognized:
5736`identifier`
5737 ~ Either a string value or an object with fields `text` and
5738 `scheme`. Valid values for `scheme` are `ISBN-10`,
5739 `GTIN-13`, `UPC`, `ISMN-10`, `DOI`, `LCCN`, `GTIN-14`,
5740 `ISBN-13`, `Legal deposit number`, `URN`, `OCLC`,
5741 `ISMN-13`, `ISBN-A`, `JP`, `OLCC`.
5743`title`
5744 ~ Either a string value, or an object with fields `file-as` and
5745 `type`, or a list of such objects. Valid values for `type` are
5746 `main`, `subtitle`, `short`, `collection`, `edition`, `extended`.
5748`creator`
5749 ~ Either a string value, or an object with fields `role`, `file-as`,
5750 and `text`, or a list of such objects. Valid values for `role` are
5751 [MARC relators], but
5752 pandoc will attempt to translate the human-readable versions
5753 (like "author" and "editor") to the appropriate marc relators.
5755`contributor`
5756 ~ Same format as `creator`.
5758`date`
5759 ~ A string value in `YYYY-MM-DD` format. (Only the year is necessary.)
5760 Pandoc will attempt to convert other common date formats.
5762`lang` (or legacy: `language`)
5763 ~ A string value in [BCP 47] format. Pandoc will default to the local
5764 language if nothing is specified.
5766`subject`
5767 ~ A string value or a list of such values.
5769`description`
5770 ~ A string value.
5772`type`
5773 ~ A string value.
5775`format`
5776 ~ A string value.
5778`relation`
5779 ~ A string value.
5781`coverage`
5782 ~ A string value.
5784`rights`
5785 ~ A string value.
5787`cover-image`
5788 ~ A string value (path to cover image).
5790`css` (or legacy: `stylesheet`)
5791 ~ A string value (path to CSS stylesheet).
5793`page-progression-direction`
5794 ~ Either `ltr` or `rtl`. Specifies the `page-progression-direction`
5795 attribute for the [`spine` element].
5797`ibooks`
5798 ~ iBooks-specific metadata, with the following fields:
5800 - `version`: (string)
5801 - `specified-fonts`: `true`|`false` (default `false`)
5802 - `ipad-orientation-lock`: `portrait-only`|`landscape-only`
5803 - `iphone-orientation-lock`: `portrait-only`|`landscape-only`
5804 - `binding`: `true`|`false` (default `true`)
5805 - `scroll-axis`: `vertical`|`horizontal`|`default`
5807[MARC relators]: https://loc.gov/marc/relators/relaterm.html
5808[`spine` element]: http://idpf.org/epub/301/spec/epub-publications.html#sec-spine-elem
5810## The `epub:type` attribute
5812For `epub3` output, you can mark up the heading that corresponds to an EPUB
5813chapter using the [`epub:type` attribute][epub-type]. For example, to set
5814the attribute to the value `prologue`, use this markdown:
5816 # My chapter {epub:type=prologue}
5818Which will result in:
5820 <body epub:type="frontmatter">
5821 <section epub:type="prologue">
5822 <h1>My chapter</h1>
5824Pandoc will output `<body epub:type="bodymatter">`, unless
5825you use one of the following values, in which case either
5826`frontmatter` or `backmatter` will be output.
5828`epub:type` of first section `epub:type` of body
5829---------------------------- ------------------
5830prologue frontmatter
5831abstract frontmatter
5832acknowledgments frontmatter
5833copyright-page frontmatter
5834dedication frontmatter
5835credits frontmatter
5836keywords frontmatter
5837imprint frontmatter
5838contributors frontmatter
5839other-credits frontmatter
5840errata frontmatter
5841revision-history frontmatter
5842titlepage frontmatter
5843halftitlepage frontmatter
5844seriespage frontmatter
5845foreword frontmatter
5846preface frontmatter
5847appendix backmatter
5848colophon backmatter
5849bibliography backmatter
5850index backmatter
5852[epub-type]: http://www.idpf.org/epub/31/spec/epub-contentdocs.html#sec-epub-type-attribute
5854## Linked media
5856By default, pandoc will download media referenced from any `<img>`, `<audio>`,
5857`<video>` or `<source>` element present in the generated EPUB,
5858and include it in the EPUB container, yielding a completely
5859self-contained EPUB. If you want to link to external media resources
5860instead, use raw HTML in your source and add `data-external="1"` to the tag
5861with the `src` attribute. For example:
5863 <audio controls="1">
5864 <source src="https://example.com/music/toccata.mp3"
5865 data-external="1" type="audio/mpeg">
5866 </source>
5867 </audio>
5869# Jupyter notebooks
5871When creating a [Jupyter notebook], pandoc will try to infer the
5872notebook structure. Code blocks with the class `code` will be
5873taken as code cells, and intervening content will be taken as
5874Markdown cells. Attachments will automatically be created for
5875images in Markdown cells. Metadata will be taken from the
5876`jupyter` metadata field. For example:
5878````
5879---
5880title: My notebook
5881jupyter:
5882 nbformat: 4
5883 nbformat_minor: 5
5884 kernelspec:
5885 display_name: Python 2
5886 language: python
5887 name: python2
5888 language_info:
5889 codemirror_mode:
5890 name: ipython
5891 version: 2
5892 file_extension: ".py"
5893 mimetype: "text/x-python"
5894 name: "python"
5895 nbconvert_exporter: "python"
5896 pygments_lexer: "ipython2"
5897 version: "2.7.15"
5898---
5900# Lorem ipsum
5902**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus
5903bibendum felis dictum sodales.
5905``` code
5906print("hello")
5907```
5909## Pyout
5911``` code
5912from IPython.display import HTML
5913HTML("""
5914<script>
5915console.log("hello");
5916</script>
5917<b>HTML</b>
5918""")
5919```
5921## Image
5923This image ![image](myimage.png) will be
5924included as a cell attachment.
5925````
5927If you want to add cell attributes, group cells differently, or
5928add output to code cells, then you need to include divs to
5929indicate the structure. You can use either [fenced
5930divs][Extension: `fenced_divs`] or [native divs][Extension:
5931`native_divs`] for this. Here is an example:
5933````
5934:::::: {.cell .markdown}
5935# Lorem
5937**Lorem ipsum** dolor sit amet, consectetur adipiscing elit. Nunc luctus
5938bibendum felis dictum sodales.
5939::::::
5941:::::: {.cell .code execution_count=1}
5942``` {.python}
5943print("hello")
5944```
5946::: {.output .stream .stdout}
5947```
5948hello
5949```
5950:::
5951::::::
5953:::::: {.cell .code execution_count=2}
5954``` {.python}
5955from IPython.display import HTML
5956HTML("""
5957<script>
5958console.log("hello");
5959</script>
5960<b>HTML</b>
5961""")
5962```
5964::: {.output .execute_result execution_count=2}
5965```{=html}
5966<script>
5967console.log("hello");
5968</script>
5969<b>HTML</b>
5970hello
5971```
5972:::
5973::::::
5974````
5976If you include raw HTML or TeX in an output cell, use the
5977[raw attribute][Extension: `fenced_attribute`], as shown
5978in the last cell of the example above. Although pandoc can
5979process "bare" raw HTML and TeX, the result is often
5980interspersed raw elements and normal textual elements, and
5981in an output cell pandoc expects a single, connected raw
5982block. To avoid using raw HTML or TeX except when
5983marked explicitly using raw attributes, we recommend
5984specifying the extensions `-raw_html-raw_tex+raw_attribute` when
5985translating between Markdown and ipynb notebooks.
5987Note that options and extensions that affect reading and
5988writing of Markdown will also affect Markdown cells in ipynb
5989notebooks. For example, `--wrap=preserve` will preserve
5990soft line breaks in Markdown cells; `--atx-headers` will
5991cause ATX-style headings to be used; and `--preserve-tabs` will
5992prevent tabs from being turned to spaces.
5994# Syntax highlighting
5996Pandoc will automatically highlight syntax in [fenced code blocks] that
5997are marked with a language name. The Haskell library [skylighting] is
5998used for highlighting. Currently highlighting is supported only for
5999HTML, EPUB, Docx, Ms, and LaTeX/PDF output. To see a list of language names
6000that pandoc will recognize, type `pandoc --list-highlight-languages`.
6002The color scheme can be selected using the `--highlight-style` option.
6003The default color scheme is `pygments`, which imitates the default color
6004scheme used by the Python library pygments (though pygments is not actually
6005used to do the highlighting). To see a list of highlight styles,
6006type `pandoc --list-highlight-styles`.
6008If you are not satisfied with the predefined styles, you can
6009use `--print-highlight-style` to generate a JSON `.theme` file which
6010can be modified and used as the argument to `--highlight-style`. To
6011get a JSON version of the `pygments` style, for example:
6013 pandoc --print-highlight-style pygments > my.theme
6015Then edit `my.theme` and use it like this:
6017 pandoc --highlight-style my.theme
6019If you are not satisfied with the built-in highlighting, or you
6020want highlight a language that isn't supported, you can use the
6021`--syntax-definition` option to load a [KDE-style XML syntax definition
6022file](https://docs.kde.org/stable5/en/applications/katepart/highlight.html).
6023Before writing your own, have a look at KDE's [repository of syntax
6024definitions](https://github.com/KDE/syntax-highlighting/tree/master/data/syntax).
6026To disable highlighting, use the `--no-highlight` option.
6028[skylighting]: https://github.com/jgm/skylighting
6030# Custom Styles
6032Custom styles can be used in the docx and ICML formats.
6034## Output
6036By default, pandoc's docx and ICML output applies a predefined set of styles
6037for blocks such as paragraphs and block quotes, and uses largely default
6038formatting (italics, bold) for inlines. This will work for most
6039purposes, especially alongside a `reference.docx` file. However, if you
6040need to apply your own styles to blocks, or match a preexisting set of
6041styles, pandoc allows you to define custom styles for blocks and text
6042using `div`s and `span`s, respectively.
6044If you define a `div` or `span` with the attribute `custom-style`,
6045pandoc will apply your specified style to the contained elements (with
6046the exception of elements whose function depends on a style, like
6047headings, code blocks, block quotes, or links). So, for example, using
6048the `bracketed_spans` syntax,
6050 [Get out]{custom-style="Emphatically"}, he said.
6052would produce a docx file with "Get out" styled with character
6053style `Emphatically`. Similarly, using the `fenced_divs` syntax,
6055 Dickinson starts the poem simply:
6057 ::: {custom-style="Poetry"}
6058 | A Bird came down the Walk---
6059 | He did not know I saw---
6060 :::
6062would style the two contained lines with the `Poetry` paragraph style.
6064For docx output, styles will be defined in the output file as inheriting
6065from normal text, if the styles are not yet in your reference.docx.
6066If they are already defined, pandoc will not alter the definition.
6068This feature allows for greatest customization in conjunction with
6069[pandoc filters]. If you want all paragraphs after block quotes to be
6070indented, you can write a filter to apply the styles necessary. If you
6071want all italics to be transformed to the `Emphasis` character style
6072(perhaps to change their color), you can write a filter which will
6073transform all italicized inlines to inlines within an `Emphasis`
6074custom-style `span`.
6076For docx output, you don't need to enable any extensions for
6077custom styles to work.
6079[pandoc filters]: https://pandoc.org/filters.html
6081## Input
6083The docx reader, by default, only reads those styles that it can
6084convert into pandoc elements, either by direct conversion or
6085interpreting the derivation of the input document's styles.
6087By enabling the [`styles` extension](#ext-styles) in the docx reader
6088(`-f docx+styles`), you can produce output that maintains the styles
6089of the input document, using the `custom-style` class. Paragraph
6090styles are interpreted as divs, while character styles are interpreted
6091as spans.
6093For example, using the `custom-style-reference.docx` file in the test
6094directory, we have the following different outputs:
6096Without the `+styles` extension:
6098 $ pandoc test/docx/custom-style-reference.docx -f docx -t markdown
6099 This is some text.
6101 This is text with an *emphasized* text style. And this is text with a
6102 **strengthened** text style.
6104 > Here is a styled paragraph that inherits from Block Text.
6106And with the extension:
6108 $ pandoc test/docx/custom-style-reference.docx -f docx+styles -t markdown
6110 ::: {custom-style="First Paragraph"}
6111 This is some text.
6112 :::
6114 ::: {custom-style="Body Text"}
6115 This is text with an [emphasized]{custom-style="Emphatic"} text style.
6116 And this is text with a [strengthened]{custom-style="Strengthened"}
6117 text style.
6118 :::
6120 ::: {custom-style="My Block Style"}
6121 > Here is a styled paragraph that inherits from Block Text.
6122 :::
6124With these custom styles, you can use your input document as a
6125reference-doc while creating docx output (see below), and maintain the
6126same styles in your input and output files.
6128# Custom writers
6130Pandoc can be extended with custom writers written in [Lua]. (Pandoc
6131includes a Lua interpreter, so Lua need not be installed separately.)
6133To use a custom writer, simply specify the path to the Lua script
6134in place of the output format. For example:
6136 pandoc -t data/sample.lua
6138Creating a custom writer requires writing a Lua function for each
6139possible element in a pandoc document. To get a documented example
6140which you can modify according to your needs, do
6142 pandoc --print-default-data-file sample.lua
6144Note that custom writers have no default template. If you want
6145to use `--standalone` with a custom writer, you will need to
6146specify a template manually using `--template` or add a new
6147default template with the name
6148`default.NAME_OF_CUSTOM_WRITER.lua` to the `templates`
6149subdirectory of your user data directory (see [Templates]).
6151[Lua]: https://www.lua.org
6153# A note on security
6155If you use pandoc to convert user-contributed content in a web
6156application, here are some things to keep in mind:
61581. Although pandoc itself will not create or modify any files other
6159 than those you explicitly ask it create (with the exception
6160 of temporary files used in producing PDFs), a filter or custom
6161 writer could in principle do anything on your file system. Please
6162 audit filters and custom writers very carefully before using them.
61642. If your application uses pandoc as a Haskell library (rather than
6165 shelling out to the executable), it is possible to use it in a mode
6166 that fully isolates pandoc from your file system, by running the
6167 pandoc operations in the `PandocPure` monad. See the document
6168 [Using the pandoc API](https://pandoc.org/using-the-pandoc-api.html)
6169 for more details.
61713. Pandoc's parsers can exhibit pathological performance on some
6172 corner cases. It is wise to put any pandoc operations under
6173 a timeout, to avoid DOS attacks that exploit these issues.
6174 If you are using the pandoc executable, you can add the
6175 command line options `+RTS -M512M -RTS` (for example) to limit
6176 the heap size to 512MB.
61784. The HTML generated by pandoc is not guaranteed to be safe.
6179 If `raw_html` is enabled for the Markdown input, users can
6180 inject arbitrary HTML. Even if `raw_html` is disabled,
6181 users can include dangerous content in attributes for
6182 headings, spans, and code blocks. To be safe, you should
6183 run all the generated HTML through an HTML sanitizer.
6185# Authors
6187Copyright 2006--2020 John MacFarlane (jgm@berkeley.edu). Released
6188under the [GPL], version 2 or greater. This software carries no
6189warranty of any kind. (See COPYRIGHT for full copyright and
6190warranty notices.) For a full list of contributors, see the file
6191AUTHORS.md in the pandoc source code.
6193[GPL]: https://www.gnu.org/copyleft/gpl.html "GNU General Public License"
6194[YAML]: https://yaml.org/spec/1.2/spec.html "YAML v1.2 Spec"