git.iko.soy/typeable/pandoc
on 83bb1de help sign in
2082 lines 73 kB history raw
1% Pandoc User's Guide
2% John MacFarlane
3% July 30, 2011
5Synopsis
6========
8pandoc [*options*] [*input-file*]...
10Description
11===========
13Pandoc is a [Haskell] library for converting from one markup format to
14another, and a command-line tool that uses this library. It can read
15[markdown] and (subsets of) [Textile], [reStructuredText], [HTML],
16and [LaTeX]; and it can write plain text, [markdown], [reStructuredText],
17[XHTML], [HTML 5], [LaTeX], [LaTeX beamer], [ConTeXt], [RTF], [DocBook XML],
18[OpenDocument XML], [ODT], [GNU Texinfo], [MediaWiki markup], [EPUB],
19[Textile], [groff man] pages, [Emacs Org-Mode], [AsciiDoc], and [Slidy],
20[DZSlides], or [S5] HTML slide shows.
22Pandoc's enhanced version of markdown includes syntax for footnotes,
23tables, flexible ordered lists, definition lists, delimited code blocks,
24superscript, subscript, strikeout, title blocks, automatic tables of
25contents, embedded LaTeX math, citations, and markdown inside HTML block
26elements. (These enhancements, described below under
27[Pandoc's markdown](#pandocs-markdown), can be disabled using the `--strict`
28option.)
30In contrast to most existing tools for converting markdown to HTML, which
31use regex substitutions, Pandoc has a modular design: it consists of a
32set of readers, which parse text in a given format and produce a native
33representation of the document, and a set of writers, which convert
34this native representation into a target format. Thus, adding an input
35or output format requires only adding a reader or writer.
37Using Pandoc
38------------
40If no *input-file* is specified, input is read from *stdin*.
41Otherwise, the *input-files* are concatenated (with a blank
42line between each) and used as input. Output goes to *stdout* by
43default (though output to *stdout* is disabled for the `odt` and
44`epub` output formats). For output to a file, use the `-o` option:
46 pandoc -o output.html input.txt
48Instead of a file, an absolute URI may be given. In this case
49pandoc will fetch the content using HTTP:
51 pandoc -f html -t markdown http://www.fsf.org
53If multiple input files are given, `pandoc` will concatenate them all (with
54blank lines between them) before parsing.
56The format of the input and output can be specified explicitly using
57command-line options. The input format can be specified using the
58`-r/--read` or `-f/--from` options, the output format using the
59`-w/--write` or `-t/--to` options. Thus, to convert `hello.txt` from
60markdown to LaTeX, you could type:
62 pandoc -f markdown -t latex hello.txt
64To convert `hello.html` from html to markdown:
66 pandoc -f html -t markdown hello.html
68Supported output formats are listed below under the `-t/--to` option.
69Supported input formats are listed below under the `-f/--from` option. Note
70that the `rst`, `textile`, `latex`, and `html` readers are not complete;
71there are some constructs that they do not parse.
73If the input or output format is not specified explicitly, `pandoc`
74will attempt to guess it from the extensions of
75the input and output filenames. Thus, for example,
77 pandoc -o hello.tex hello.txt
79will convert `hello.txt` from markdown to LaTeX. If no output file
80is specified (so that output goes to *stdout*), or if the output file's
81extension is unknown, the output format will default to HTML.
82If no input file is specified (so that input comes from *stdin*), or
83if the input files' extensions are unknown, the input format will
84be assumed to be markdown unless explicitly specified.
86Pandoc uses the UTF-8 character encoding for both input and output.
87If your local character encoding is not UTF-8, you
88should pipe input and output through `iconv`:
90 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
92Wrappers
93========
95`markdown2pdf`
96--------------
98The standard Pandoc installation includes `markdown2pdf`, a wrapper
99around `pandoc` and `pdflatex` that produces PDFs directly from markdown
100sources. The default behavior of `markdown2pdf` is to create a file with
101the same base name as the first argument and the extension `pdf`; thus,
102for example,
104 markdown2pdf sample.txt endnotes.txt
106will produce `sample.pdf`. An output file
107name can be specified explicitly using the `-o` option:
109 markdown2pdf -o book.pdf chap1 chap2
111If no input file is specified, input will be taken from *stdin*.
112All of `pandoc`'s options will work with `markdown2pdf` as well.
114`markdown2pdf` assumes that `pdflatex` is in the path. It also
115assumes that the following LaTeX packages are available:
116`unicode`, `fancyhdr` (if you have verbatim text in footnotes),
117`graphicx` (if you use images), `array` (if you use tables),
118and `ulem` (if you use strikeout text). If they are not already
119included in your LaTeX distribution, you can get them from
120[CTAN]. A full [TeX Live] or [MacTeX] distribution will have all of
121these packages.
123`hsmarkdown`
124------------
126A user who wants a drop-in replacement for `Markdown.pl` may create
127a symbolic link to the `pandoc` executable called `hsmarkdown`. When
128invoked under the name `hsmarkdown`, `pandoc` will behave as if the
129`--strict` flag had been selected, and no command-line options will be
130recognized. However, this approach does not work under Cygwin, due to
131problems with its simulation of symbolic links.
133[Cygwin]: http://www.cygwin.com/
134[`iconv`]: http://www.gnu.org/software/libiconv/
135[CTAN]: http://www.ctan.org "Comprehensive TeX Archive Network"
136[TeX Live]: http://www.tug.org/texlive/
137[MacTeX]: http://www.tug.org/mactex/
139Options
140=======
142`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*
143: Specify input format. *FORMAT* can be `native` (native Haskell),
144 `json` (JSON version of native AST), `markdown` (markdown),
145 `textile` (Textile), `rst` (reStructuredText), `html` (HTML),
146 or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`,
147 or `latex`, the input will be treated as literate Haskell source:
148 see [Literate Haskell support](#literate-haskell-support),
149 below.
151`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
152: Specify output format. *FORMAT* can be `native` (native Haskell),
153 `json` (JSON version of native AST), `plain` (plain text),
154 `markdown` (markdown), `rst` (reStructuredText), `html` (XHTML 1),
155 `html5` (HTML 5), `latex` (LaTeX), `beamer` (LaTeX beamer), `context`
156 (ConTeXt), `man` (groff man), `mediawiki` (MediaWiki markup), `textile`
157 (Textile), `org` (Emacs Org-Mode), `texinfo` (GNU Texinfo), `docbook`
158 (DocBook XML), `opendocument` (OpenDocument XML), `odt` (OpenOffice text
159 document), `epub` (EPUB book), `asciidoc` (AsciiDoc), `slidy` (Slidy HTML
160 and javascript slide show), `dzslides` (HTML5 + javascript slide show),
161 `s5` (S5 HTML and javascript slide show), or `rtf` (rich text format).
162 Note that `odt` and `epub` output will not be directed to *stdout*;
163 an output filename must be specified using the `-o/--output` option.
164 If `+lhs` is appended to `markdown`, `rst`, `latex`, `html`, or `html5`,
165 the output will be rendered as literate Haskell source: see [Literate
166 Haskell support](#literate-haskell-support), below.
168`-s`, `--standalone`
169: Produce output with an appropriate header and footer (e.g. a
170 standalone HTML, LaTeX, or RTF file, not a fragment).
172`-o` *FILE*, `--output=`*FILE*
173: Write output to *FILE* instead of *stdout*. If *FILE* is
174 `-`, output will go to *stdout*. (Exception: if the output
175 format is `odt` or `epub`, output to stdout is disabled.)
177`-p`, `--preserve-tabs`
178: Preserve tabs instead of converting them to spaces (the default).
180`--tab-stop=`*NUMBER*
181: Specify the number of spaces per tab (default is 4).
183`--strict`
184: Use strict markdown syntax, with no pandoc extensions or variants.
185 When the input format is HTML, this means that constructs that have no
186 equivalents in standard markdown (e.g. definition lists or strikeout
187 text) will be parsed as raw HTML.
189`--normalize`
190: Normalize the document after reading: merge adjacent
191 `Str` or `Emph` elements, for example, and remove repeated `Space`s.
193`--reference-links`
194: Use reference-style links, rather than inline links, in writing markdown
195 or reStructuredText. By default inline links are used.
197`-R`, `--parse-raw`
198: Parse untranslatable HTML codes and LaTeX environments as raw HTML
199 or LaTeX, instead of ignoring them. Affects only HTML and LaTeX
200 input. Raw HTML can be printed in markdown, reStructuredText, HTML, Slidy,
201 DZSlides, and S5 output; raw LaTeX can be printed in markdown,
202 reStructuredText, LaTeX, and ConTeXt output. The default is for the
203 readers to omit untranslatable HTML codes and LaTeX environments.
204 (The LaTeX reader does pass through untranslatable LaTeX *commands*,
205 even if `-R` is not specified.)
207`-S`, `--smart`
208: Produce typographically correct output, converting straight quotes
209 to curly quotes, `---` to em-dashes, `--` to en-dashes, and
210 `...` to ellipses. Nonbreaking spaces are inserted after certain
211 abbreviations, such as "Mr." (Note: This option is significant only when
212 the input format is `markdown` or `textile`. It is selected automatically
213 when the input format is `textile` or the output format is `latex` or
214 `context`.)
216`--old-dashes`
217: Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes: `-` before
218 a numeral is an en-dash, and `--` is an em-dash. This option is selected
219 automatically for `textile` input.
221`-5`, `--html5`
222: Produce HTML5 instead of HTML4. This option has no effect for writers
223 other than `html`. (*Deprecated:* Use the `html5` output format instead.)
225`--no-highlight`
226: Disables syntax highlighting for code blocks and inlines, even when
227 a language attribute is given.
229`--highlight-style`=*STYLE*
230: Specifies the coloring style to be used in highlighted source code.
231 Options are `pygments` (the default), `kate`, `monochrome`,
232 `espresso`, `haddock`, and `tango`.
234`-m` [*URL*], `--latexmathml`[=*URL*]
235: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.
236 To insert a link to a local copy of the `LaTeXMathML.js` script,
237 provide a *URL*. If no *URL* is provided, the contents of the
238 script will be inserted directly into the HTML header, preserving
239 portability at the price of efficiency. If you plan to use math on
240 several pages, it is much better to link to a copy of the script,
241 so it can be cached.
243`--mathml`[=*URL*]
244: Convert TeX math to MathML. In standalone mode, a small javascript
245 (or a link to such a script if a *URL* is supplied) will be inserted that
246 allows the MathML to be viewed on some browsers.
248`--jsmath`[=*URL*]
249: Use [jsMath] to display embedded TeX math in HTML output.
250 The *URL* should point to the jsMath load script (e.g.
251 `jsMath/easy/load.js`); if provided, it will be linked to in
252 the header of standalone HTML documents. If a *URL* is not provided,
253 no link to the jsMath load script will be inserted; it is then
254 up to the author to provide such a link in the HTML template.
256`--mathjax`[=*URL*]
257: Use [MathJax] to display embedded TeX math in HTML output.
258 The *URL* should point to the `MathJax.js` load script.
259 If a *URL* is not provided, a link to the MathJax CDN will
260 be inserted.
262`--gladtex`
263: Enclose TeX math in `<eq>` tags in HTML output. These can then
264 be processed by [gladTeX] to produce links to images of the typeset
265 formulas.
267`--mimetex`[=*URL*]
268: Render TeX math using the [mimeTeX] CGI script. If *URL* is not
269 specified, it is assumed that the script is at `/cgi-bin/mimetex.cgi`.
271`--webtex`[=*URL*]
272: Render TeX formulas using an external script that converts TeX
273 formulas to images. The formula will be concatenated with the URL
274 provided. If *URL* is not specified, the Google Chart API will be used.
276`-i`, `--incremental`
277: Make list items in Slidy, DZSlides or S5 display incrementally (one by one).
278 The default is for lists to be displayed all at once.
280`--self-contained`
281: Produce a standalone HTML file with no external dependencies, using
282 `data:` URIs to incorporate the contents of linked scripts, stylesheets,
283 images, and videos. The resulting file should be "self-contained,"
284 in the sense that it needs no external files and no net access to be
285 displayed properly by a browser. This option works only with HTML output
286 formats, including `html`, `html5`, `html+lhs`, `html5+lhs`, `s5`,
287 `slidy`, and `dzslides`. Scripts, images, and stylesheets at absolute URLs
288 will be downloaded; those at relative URLs will be sought first relative
289 to the working directory, then relative to the user data directory (see
290 `--data-dir`), and finally relative to pandoc's default data directory.
292`--offline`
293: Deprecated synonym for `--self-contained`.
295`--chapters`
296: Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook
297 output. When the LaTeX template uses the report, book, or
298 memoir class, this option is implied.
300`-N`, `--number-sections`
301: Number section headings in LaTeX, ConTeXt, or HTML output.
302 By default, sections are not numbered.
304`--listings`
305: Use listings package for LaTeX code blocks
307`--section-divs`
308: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),
309 and attach identifiers to the enclosing `<div>` (or `<section>`)
310 rather than the header itself.
311 See [Section identifiers](#header-identifiers-in-html), below.
313`--no-wrap`
314: Disable text wrapping in output. By default, text is wrapped
315 appropriately for the output format.
317`--columns`=*NUMBER*
318: Specify length of lines in characters (for text wrapping).
320`--email-obfuscation=`*none|javascript|references*
321: Specify a method for obfuscating `mailto:` links in HTML documents.
322 *none* leaves `mailto:` links as they are. *javascript* obfuscates
323 them using javascript. *references* obfuscates them by printing their
324 letters as decimal or hexadecimal character references.
325 If `--strict` is specified, *references* is used regardless of the
326 presence of this option.
328`--id-prefix`=*STRING*
329: Specify a prefix to be added to all automatically generated identifiers
330 in HTML output. This is useful for preventing duplicate identifiers
331 when generating fragments to be included in other pages.
333`--indented-code-classes=`*CLASSES*
334: Specify classes to use for indented code blocks--for example,
335 `perl,numberLines` or `haskell`. Multiple classes may be separated
336 by spaces or commas.
338`--toc`, `--table-of-contents`
339: Include an automatically generated table of contents (or, in
340 the case of `latex`, `context`, and `rst`, an instruction to create
341 one) in the output document. This option has no effect on `man`,
342 `docbook`, `slidy`, or `s5` output.
344`--base-header-level=`*NUMBER*
345: Specify the base level for headers (defaults to 1).
347`--template=`*FILE*
348: Use *FILE* as a custom template for the generated document. Implies
349 `--standalone`. See [Templates](#templates) below for a description
350 of template syntax. If no extension is specified, an extension
351 corresponding to the writer will be added, so that `--template=special`
352 looks for `special.html` for HTML output. If the template is not
353 found, pandoc will search for it in the user data directory
354 (see `--data-dir`). If this option is not used, a default
355 template appropriate for the output format will be used (see
356 `-D/--print-default-template`).
358`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
359: Set the template variable *KEY* to the value *VAL* when rendering the
360 document in standalone mode. This is generally only useful when the
361 `--template` option is used to specify a custom template, since
362 pandoc automatically sets the variables used in the default
363 templates.
365`-c` *URL*, `--css=`*URL*
366: Link to a CSS style sheet.
368`-H` *FILE*, `--include-in-header=`*FILE*
369: Include contents of *FILE*, verbatim, at the end of the header.
370 This can be used, for example, to include special
371 CSS or javascript in HTML documents. This option can be used
372 repeatedly to include multiple files in the header. They will be
373 included in the order specified. Implies `--standalone`.
375`-B` *FILE*, `--include-before-body=`*FILE*
376: Include contents of *FILE*, verbatim, at the beginning of the
377 document body (e.g. after the `<body>` tag in HTML, or the
378 `\begin{document}` command in LaTeX). This can be used to include
379 navigation bars or banners in HTML documents. This option can be
380 used repeatedly to include multiple files. They will be included in
381 the order specified. Implies `--standalone`.
383`-A` *FILE*, `--include-after-body=`*FILE*
384: Include contents of *FILE*, verbatim, at the end of the document
385 body (before the `</body>` tag in HTML, or the
386 `\end{document}` command in LaTeX). This option can be be used
387 repeatedly to include multiple files. They will be included in the
388 order specified. Implies `--standalone`.
390`--reference-odt=`*FILE*
391: Use the specified file as a style reference in producing an ODT.
392 For best results, the reference ODT should be a modified version
393 of an ODT produced using pandoc. The contents of the reference ODT
394 are ignored, but its stylesheets are used in the new ODT. If no
395 reference ODT is specified on the command line, pandoc will look
396 for a file `reference.odt` in the user data directory (see
397 `--data-dir`). If this is not found either, sensible defaults will be
398 used.
400`--epub-stylesheet=`*FILE*
401: Use the specified CSS file to style the EPUB. If no stylesheet
402 is specified, pandoc will look for a file `epub.css` in the
403 user data directory (see `--data-dir`, below). If it is not
404 found there, sensible defaults will be used.
406`--epub-cover-image=`*FILE*
407: Use the specified image as the EPUB cover. It is recommended
408 that the image be less than 1000px in width and height.
410`--epub-metadata=`*FILE*
411: Look in the specified XML file for metadata for the EPUB.
412 The file should contain a series of Dublin Core elements,
413 as documented at <http://dublincore.org/documents/dces/>.
414 For example:
416 <dc:rights>Creative Commons</dc:rights>
417 <dc:language>es-AR</dc:language>
419 By default, pandoc will include the following metadata elements:
420 `<dc:title>` (from the document title), `<dc:creator>` (from the
421 document authors), `<dc:date>` (from the document date, which should
422 be is in [ISO 8601 format]), `<dc:language>` (from the `lang`
423 variable, or, if is not set, the locale), and `<dc:identifier
424 id="BookId">` (a randomly generated UUID). Any of these may be
425 overridden by elements in the metadata file.
427`-D` *FORMAT*, `--print-default-template=`*FORMAT*
428: Print the default template for an output *FORMAT*. (See `-t`
429 for a list of possible *FORMAT*s.)
431`-T` *STRING*, `--title-prefix=`*STRING*
432: Specify *STRING* as a prefix at the beginning of the title
433 that appears in the HTML header (but not in the title as it
434 appears at the beginning of the HTML body). Implies
435 `--standalone`.
437`--bibliography=`*FILE*
438: Specify bibliography database to be used in resolving
439 citations. The database type will be determined from the
440 extension of *FILE*, which may be `.mods` (MODS format),
441 `.bib` (BibTeX/BibLaTeX format),
442 `.ris` (RIS format), `.enl` (EndNote format),
443 `.xml` (EndNote XML format), `.wos` (ISI format),
444 `.medline` (MEDLINE format), `.copac` (Copac format),
445 or `.json` (citeproc JSON). If you want to use multiple
446 bibliographies, just use this option repeatedly.
448`--csl=`*FILE*
449: Specify [CSL] style to be used in formatting citations and
450 the bibliography. If *FILE* is not found, pandoc will look
451 for it in
453 $HOME/.csl
455 in unix and
457 C:\Documents And Settings\USERNAME\Application Data\csl
459 in Windows. If the `--csl` option is not specified, pandoc
460 will use a default style: either `default.csl` in the
461 user data directory (see `--data-dir`), or, if that is
462 not present, the Chicago author-date style.
464`--citation-abbreviations=`*FILE*
465: Specify a file containing abbreviations for journal titles and
466 other bibliographic fields (indicated by setting `form="short"`
467 in the CSL node for the field). The format is described at
468 <http://citationstylist.org/2011/10/19/abbreviations-for-zotero-test-release/>.
469 Here is a short example:
471 { "default": {
472 "container-title": {
473 "Lloyd's Law Reports": "Lloyd's Rep",
474 "Estates Gazette": "EG",
475 "Scots Law Times": "SLT"
476 }
477 }
478 }
480`--natbib`
481: Use natbib for citations in LaTeX output.
483`--biblatex`
484: Use biblatex for citations in LaTeX output.
486`--data-dir=`*DIRECTORY*
487: Specify the user data directory to search for pandoc data files.
488 If this option is not specified, the default user data directory
489 will be used:
491 $HOME/.pandoc
493 in unix and
495 C:\Documents And Settings\USERNAME\Application Data\pandoc
497 in Windows. A `reference.odt`, `epub.css`, `templates` directory,
498 or `s5` directory placed in this directory will override pandoc's
499 normal defaults.
501`--dump-args`
502: Print information about command-line arguments to *stdout*, then exit.
503 This option is intended primarily for use in wrapper scripts.
504 The first line of output contains the name of the output file specified
505 with the `-o` option, or `-` (for *stdout*) if no output file was
506 specified. The remaining lines contain the command-line arguments,
507 one per line, in the order they appear. These do not include regular
508 Pandoc options and their arguments, but do include any options appearing
509 after a `--` separator at the end of the line.
511`--ignore-args`
512: Ignore command-line arguments (for use in wrapper scripts).
513 Regular Pandoc options are not ignored. Thus, for example,
515 pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
517 is equivalent to
519 pandoc -o foo.html -s
521`-v`, `--version`
522: Print version.
524`-h`, `--help`
525: Show usage message.
527[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/
528[jsMath]: http://www.math.union.edu/~dpvc/jsmath/
529[MathJax]: http://www.mathjax.org/
530[gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html
531[mimeTeX]: http://www.forkosh.com/mimetex.html
532[CSL]: http://CitationStyles.org
534Templates
535=========
537When the `-s/--standalone` option is used, pandoc uses a template to
538add header and footer material that is needed for a self-standing
539document. To see the default template that is used, just type
541 pandoc -D FORMAT
543where `FORMAT` is the name of the output format. A custom template
544can be specified using the `--template` option. You can also override
545the system default templates for a given output format `FORMAT`
546by putting a file `templates/default.FORMAT` in the user data
547directory (see `--data-dir`, above).
549Templates may contain *variables*. Variable names are sequences of
550alphanumerics, `-`, and `_`, starting with a letter. A variable name
551surrounded by `$` signs will be replaced by its value. For example,
552the string `$title$` in
554 <title>$title$</title>
556will be replaced by the document title.
558To write a literal `$` in a template, use `$$`.
560Some variables are set automatically by pandoc. These vary somewhat
561depending on the output format, but include:
563`header-includes`
564: contents specified by `-H/--include-in-header` (may have multiple
565 values)
566`toc`
567: non-null value if `--toc/--table-of-contents` was specified
568`include-before`
569: contents specified by `-B/--include-before-body` (may have
570 multiple values)
571`include-after`
572: contents specified by `-A/--include-after-body` (may have
573 multiple values)
574`body`
575: body of document
576`title`
577: title of document, as specified in title block
578`author`
579: author of document, as specified in title block (may have
580 multiple values)
581`date`
582: date of document, as specified in title block
583`lang`
584: language code for HTML or LaTeX documents
585`slidy-url`
586: base URL for Slidy documents (defaults to
587 `http://www.w3.org/Talks/Tools/Slidy2`)
588`s5-url`
589: base URL for S5 documents (defaults to `ui/default`)
590`font-size`
591: font size (10pt, 11pt, 12pt) for LaTeX and beamer documents
592`documentclass`
593: document class for LaTeX documents
594`theme`
595: theme for beamer documents
596`colortheme`
597: colortheme for beamer documents
599Variables may be set at the command line using the `-V/--variable`
600option. This allows users to include custom variables in their
601templates.
603Templates may contain conditionals. The syntax is as follows:
605 $if(variable)$
606 X
607 $else$
608 Y
609 $endif$
611This will include `X` in the template if `variable` has a non-null
612value; otherwise it will include `Y`. `X` and `Y` are placeholders for
613any valid template text, and may include interpolated variables or other
614conditionals. The `$else$` section may be omitted.
616When variables can have multiple values (for example, `author` in
617a multi-author document), you can use the `$for$` keyword:
619 $for(author)$
620 <meta name="author" content="$author$" />
621 $endfor$
623You can optionally specify a separator to be used between
624consecutive items:
626 $for(author)$$author$$sep$, $endfor$
628If you use custom templates, you may need to revise them as pandoc
629changes. We recommend tracking the changes in the default templates,
630and modifying your custom templates accordingly. An easy way to do this
631is to fork the pandoc-templates repository
632(<http://github.com/jgm/pandoc-templates>) and merge in changes after each
633pandoc release.
635Pandoc's markdown
636=================
638Pandoc understands an extended and slightly revised version of
639John Gruber's [markdown] syntax. This document explains the syntax,
640noting differences from standard markdown. Except where noted, these
641differences can be suppressed by specifying the `--strict` command-line
642option.
644Philosophy
645----------
647Markdown is designed to be easy to write, and, even more importantly,
648easy to read:
650> A Markdown-formatted document should be publishable as-is, as plain
651> text, without looking like it's been marked up with tags or formatting
652> instructions.
653> -- [John Gruber](http://daringfireball.net/projects/markdown/syntax#philosophy)
655This principle has guided pandoc's decisions in finding syntax for
656tables, footnotes, and other extensions.
658There is, however, one respect in which pandoc's aims are different
659from the original aims of markdown. Whereas markdown was originally
660designed with HTML generation in mind, pandoc is designed for multiple
661output formats. Thus, while pandoc allows the embedding of raw HTML,
662it discourages it, and provides other, non-HTMLish ways of representing
663important document elements like definition lists, tables, mathematics, and
664footnotes.
666Paragraphs
667----------
669A paragraph is one or more lines of text followed by one or more blank line.
670Newlines are treated as spaces, so you can reflow your paragraphs as you like.
671If you need a hard line break, put two or more spaces at the end of a line,
672or type a backslash followed by a newline.
674Headers
675-------
677There are two kinds of headers, Setext and atx.
679### Setext-style headers ###
681A setext-style header is a line of text "underlined" with a row of `=` signs
682(for a level one header) of `-` signs (for a level two header):
684 A level-one header
685 ==================
687 A level-two header
688 ------------------
690The header text can contain inline formatting, such as emphasis (see
691[Inline formatting](#inline-formatting), below).
694### Atx-style headers ###
696An Atx-style header consists of one to six `#` signs and a line of
697text, optionally followed by any number of `#` signs. The number of
698`#` signs at the beginning of the line is the header level:
700 ## A level-two header
702 ### A level-three header ###
704As with setext-style headers, the header text can contain formatting:
706 # A level-one header with a [link](/url) and *emphasis*
708Standard markdown syntax does not require a blank line before a header.
709Pandoc does require this (except, of course, at the beginning of the
710document). The reason for the requirement is that it is all too easy for a
711`#` to end up at the beginning of a line by accident (perhaps through line
712wrapping). Consider, for example:
714 I like several of their flavors of ice cream:
715 #22, for example, and #5.
718### Header identifiers in HTML, LaTeX, and ConTeXt ###
720*Pandoc extension*.
722Each header element in pandoc's HTML and ConTeXt output is given a
723unique identifier. This identifier is based on the text of the header.
724To derive the identifier from the header text,
726 - Remove all formatting, links, etc.
727 - Remove all punctuation, except underscores, hyphens, and periods.
728 - Replace all spaces and newlines with hyphens.
729 - Convert all alphabetic characters to lowercase.
730 - Remove everything up to the first letter (identifiers may
731 not begin with a number or punctuation mark).
732 - If nothing is left after this, use the identifier `section`.
734Thus, for example,
736 Header Identifier
737 ------------------------------- ----------------------------
738 Header identifiers in HTML `header-identifiers-in-html`
739 *Dogs*?--in *my* house? `dogs--in-my-house`
740 [HTML], [S5], or [RTF]? `html-s5-or-rtf`
741 3. Applications `applications`
742 33 `section`
744These rules should, in most cases, allow one to determine the identifier
745from the header text. The exception is when several headers have the
746same text; in this case, the first will get an identifier as described
747above; the second will get the same identifier with `-1` appended; the
748third with `-2`; and so on.
750These identifiers are used to provide link targets in the table of
751contents generated by the `--toc|--table-of-contents` option. They
752also make it easy to provide links from one section of a document to
753another. A link to this section, for example, might look like this:
755 See the section on
756 [header identifiers][#header-identifiers-in-html].
758Note, however, that this method of providing links to sections works
759only in HTML, LaTeX, and ConTeXt formats.
761If the `--section-divs` option is specified, then each section will
762be wrapped in a `div` (or a `section`, if `--html5` was specified),
763and the identifier will be attached to the enclosing `<div>`
764(or `<section>`) tag rather than the header itself. This allows entire
765sections to be manipulated using javascript or treated differently in
766CSS.
769Block quotations
770----------------
772Markdown uses email conventions for quoting blocks of text.
773A block quotation is one or more paragraphs or other block elements
774(such as lists or headers), with each line preceded by a `>` character
775and a space. (The `>` need not start at the left margin, but it should
776not be indented more than three spaces.)
778 > This is a block quote. This
779 > paragraph has two lines.
780 >
781 > 1. This is a list inside a block quote.
782 > 2. Second item.
784A "lazy" form, which requires the `>` character only on the first
785line of each block, is also allowed:
787 > This is a block quote. This
788 paragraph has two lines.
790 > 1. This is a list inside a block quote.
791 2. Second item.
793Among the block elements that can be contained in a block quote are
794other block quotes. That is, block quotes can be nested:
796 > This is a block quote.
797 >
798 > > A block quote within a block quote.
800Standard markdown syntax does not require a blank line before a block
801quote. Pandoc does require this (except, of course, at the beginning of the
802document). The reason for the requirement is that it is all too easy for a
803`>` to end up at the beginning of a line by accident (perhaps through line
804wrapping). So, unless `--strict` is used, the following does not produce
805a nested block quote in pandoc:
807 > This is a block quote.
808 >> Nested.
811Verbatim (code) blocks
812----------------------
814### Indented code blocks ###
816A block of text indented four spaces (or one tab) is treated as verbatim
817text: that is, special characters do not trigger special formatting,
818and all spaces and line breaks are preserved. For example,
820 if (a > 3) {
821 moveShip(5 * gravity, DOWN);
822 }
824The initial (four space or one tab) indentation is not considered part
825of the verbatim text, and is removed in the output.
827Note: blank lines in the verbatim text need not begin with four spaces.
830### Delimited code blocks ###
832*Pandoc extension*.
834In addition to standard indented code blocks, Pandoc supports
835*delimited* code blocks. These begin with a row of three or more
836tildes (`~`) and end with a row of tildes that must be at least
837as long as the starting row. Everything between the tilde-lines
838is treated as code. No indentation is necessary:
840 ~~~~~~~
841 if (a > 3) {
842 moveShip(5 * gravity, DOWN);
843 }
844 ~~~~~~~
846Like regular code blocks, delimited code blocks must be separated
847from surrounding text by blank lines.
849If the code itself contains a row of tildes, just use a longer
850row of tildes at the start and end:
852 ~~~~~~~~~~~~~~~~
853 ~~~~~~~~~~
854 code including tildes
855 ~~~~~~~~~~
856 ~~~~~~~~~~~~~~~~
858Optionally, you may specify the language of the code block using
859this syntax:
861 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines}
862 qsort [] = []
863 qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
864 qsort (filter (>= x) xs)
865 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
867Some output formats can use this information to do syntax highlighting.
868Currently, the only output formats that uses this information are HTML
869and LaTeX. If highlighting is supported for your output format and language,
870then the code block above will appear highlighted, with numbered lines. (To
871see which languages are supported, do `pandoc --version`.) Otherwise, the code
872block above will appear as follows:
874 <pre class="haskell">
875 <code>
876 ...
877 </code>
878 </pre>
880To prevent all highlighting, use the `--no-highlight` flag.
881To set the highlighting style, use `--highlight-style`.
883Lists
884-----
886### Bullet lists ###
888A bullet list is a list of bulleted list items. A bulleted list
889item begins with a bullet (`*`, `+`, or `-`). Here is a simple
890example:
892 * one
893 * two
894 * three
896This will produce a "compact" list. If you want a "loose" list, in which
897each item is formatted as a paragraph, put spaces between the items:
899 * one
901 * two
903 * three
905The bullets need not be flush with the left margin; they may be
906indented one, two, or three spaces. The bullet must be followed
907by whitespace.
909List items look best if subsequent lines are flush with the first
910line (after the bullet):
912 * here is my first
913 list item.
914 * and my second.
916But markdown also allows a "lazy" format:
918 * here is my first
919 list item.
920 * and my second.
922### The four-space rule ###
924A list item may contain multiple paragraphs and other block-level
925content. However, subsequent paragraphs must be preceded by a blank line
926and indented four spaces or a tab. The list will look better if the first
927paragraph is aligned with the rest:
929 * First paragraph.
931 Continued.
933 * Second paragraph. With a code block, which must be indented
934 eight spaces:
936 { code }
938List items may include other lists. In this case the preceding blank
939line is optional. The nested list must be indented four spaces or
940one tab:
942 * fruits
943 + apples
944 - macintosh
945 - red delicious
946 + pears
947 + peaches
948 * vegetables
949 + brocolli
950 + chard
952As noted above, markdown allows you to write list items "lazily," instead of
953indenting continuation lines. However, if there are multiple paragraphs or
954other blocks in a list item, the first line of each must be indented.
956 + A lazy, lazy, list
957 item.
959 + Another one; this looks
960 bad but is legal.
962 Second paragraph of second
963 list item.
965**Note:** Although the four-space rule for continuation paragraphs
966comes from the official [markdown syntax guide], the reference implementation,
967`Markdown.pl`, does not follow it. So pandoc will give different results than
968`Markdown.pl` when authors have indented continuation paragraphs fewer than
969four spaces.
971The [markdown syntax guide] is not explicit whether the four-space
972rule applies to *all* block-level content in a list item; it only
973mentions paragraphs and code blocks. But it implies that the rule
974applies to all block-level content (including nested lists), and
975pandoc interprets it that way.
977 [markdown syntax guide]:
978 http://daringfireball.net/projects/markdown/syntax#list
980### Ordered lists ###
982Ordered lists work just like bulleted lists, except that the items
983begin with enumerators rather than bullets.
985In standard markdown, enumerators are decimal numbers followed
986by a period and a space. The numbers themselves are ignored, so
987there is no difference between this list:
989 1. one
990 2. two
991 3. three
993and this one:
995 5. one
996 7. two
997 1. three
999*Pandoc extension*.
1001Unlike standard markdown, Pandoc allows ordered list items to be marked
1002with uppercase and lowercase letters and roman numerals, in addition to
1003arabic numerals. List markers may be enclosed in parentheses or followed by a
1004single right-parentheses or period. They must be separated from the
1005text that follows by at least one space, and, if the list marker is a
1006capital letter with a period, by at least two spaces.[^2]
1008[^2]: The point of this rule is to ensure that normal paragraphs
1009 starting with people's initials, like
1011 B. Russell was an English philosopher.
1013 do not get treated as list items.
1015 This rule will not prevent
1017 (C) 2007 Joe Smith
1019 from being interpreted as a list item. In this case, a backslash
1020 escape can be used:
1022 (C\) 2007 Joe Smith
1024Pandoc also pays attention to the type of list marker used, and to the
1025starting number, and both of these are preserved where possible in the
1026output format. Thus, the following yields a list with numbers followed
1027by a single parenthesis, starting with 9, and a sublist with lowercase
1028roman numerals:
1030 9) Ninth
1031 10) Tenth
1032 11) Eleventh
1033 i. subone
1034 ii. subtwo
1035 iii. subthree
1037Note that Pandoc pays attention only to the *starting* marker in a list.
1038So, the following yields a list numbered sequentially starting from 2:
1040 (2) Two
1041 (5) Three
1042 1. Four
1043 * Five
1045If default list markers are desired, use `#.`:
1047 #. one
1048 #. two
1049 #. three
1052### Definition lists ###
1054*Pandoc extension*.
1056Pandoc supports definition lists, using a syntax inspired by
1057[PHP Markdown Extra] and [reStructuredText]:[^3]
1059 Term 1
1061 : Definition 1
1063 Term 2 with *inline markup*
1065 : Definition 2
1067 { some code, part of Definition 2 }
1069 Third paragraph of definition 2.
1071Each term must fit on one line, which may optionally be followed by
1072a blank line, and must be followed by one or more definitions.
1073A definition begins with a colon or tilde, which may be indented one
1074or two spaces. The body of the definition (including the first line,
1075aside from the colon or tilde) should be indented four spaces. A term may have
1076multiple definitions, and each definition may consist of one or more block
1077elements (paragraph, code block, list, etc.), each indented four spaces or one
1078tab stop.
1080If you leave space after the definition (as in the example above),
1081the blocks of the definitions will be considered paragraphs. In some
1082output formats, this will mean greater spacing between term/definition
1083pairs. For a compact definition list, do not leave space between the
1084definition and the next term:
1086 Term 1
1087 ~ Definition 1
1088 Term 2
1089 ~ Definition 2a
1090 ~ Definition 2b
1092[^3]: I have also been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).
1094[PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
1097### Numbered example lists ###
1099*Pandoc extension*.
1101The special list marker `@` can be used for sequentially numbered
1102examples. The first list item with a `@` marker will be numbered '1',
1103the next '2', and so on, throughout the document. The numbered examples
1104need not occur in a single list; each new list using `@` will take up
1105where the last stopped. So, for example:
1107 (@) My first example will be numbered (1).
1108 (@) My second example will be numbered (2).
1110 Explanation of examples.
1112 (@) My third example will be numbered (3).
1114Numbered examples can be labeled and referred to elsewhere in the
1115document:
1117 (@good) This is a good example.
1119 As (@good) illustrates, ...
1121The label can be any string of alphanumeric characters, underscores,
1122or hyphens.
1125### Compact and loose lists ###
1127Pandoc behaves differently from `Markdown.pl` on some "edge
1128cases" involving lists. Consider this source:
1130 + First
1131 + Second:
1132 - Fee
1133 - Fie
1134 - Foe
1136 + Third
1138Pandoc transforms this into a "compact list" (with no `<p>` tags around
1139"First", "Second", or "Third"), while markdown puts `<p>` tags around
1140"Second" and "Third" (but not "First"), because of the blank space
1141around "Third". Pandoc follows a simple rule: if the text is followed by
1142a blank line, it is treated as a paragraph. Since "Second" is followed
1143by a list, and not a blank line, it isn't treated as a paragraph. The
1144fact that the list is followed by a blank line is irrelevant. (Note:
1145Pandoc works this way even when the `--strict` option is specified. This
1146behavior is consistent with the official markdown syntax description,
1147even though it is different from that of `Markdown.pl`.)
1150### Ending a list ###
1152What if you want to put an indented code block after a list?
1154 - item one
1155 - item two
1157 { my code block }
1159Trouble! Here pandoc (like other markdown implementations) will treat
1160`{ my code block }` as the second paragraph of item two, and not as
1161a code block.
1163To "cut off" the list after item two, you can insert some non-indented
1164content, like an HTML comment, which won't produce visible output in
1165any format:
1167 - item one
1168 - item two
1170 <!-- end of list -->
1172 { my code block }
1174You can use the same trick if you want two consecutive lists instead
1175of one big list:
1177 1. one
1178 2. two
1179 3. three
1181 <!-- -->
1183 a. uno
1184 b. dos
1185 c. tres
1188Horizontal rules
1189----------------
1191A line containing a row of three or more `*`, `-`, or `_` characters
1192(optionally separated by spaces) produces a horizontal rule:
1194 * * * *
1196 ---------------
1199Tables
1200------
1202*Pandoc extension*.
1204Three kinds of tables may be used. All three kinds presuppose the use of
1205a fixed-width font, such as Courier.
1207**Simple tables** look like this:
1209 Right Left Center Default
1210 ------- ------ ---------- -------
1211 12 12 12 12
1212 123 123 123 123
1213 1 1 1 1
1215 Table: Demonstration of simple table syntax.
1217The headers and table rows must each fit on one line. Column
1218alignments are determined by the position of the header text relative
1219to the dashed line below it:[^4]
1221 - If the dashed line is flush with the header text on the right side
1222 but extends beyond it on the left, the column is right-aligned.
1223 - If the dashed line is flush with the header text on the left side
1224 but extends beyond it on the right, the column is left-aligned.
1225 - If the dashed line extends beyond the header text on both sides,
1226 the column is centered.
1227 - If the dashed line is flush with the header text on both sides,
1228 the default alignment is used (in most cases, this will be left).
1230[^4]: This scheme is due to Michel Fortin, who proposed it on the
1231 [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).
1233The table must end with a blank line, or a line of dashes followed by
1234a blank line. A caption may optionally be provided (as illustrated in
1235the example above). A caption is a paragraph beginning with the string
1236`Table:` (or just `:`), which will be stripped off. It may appear either
1237before or after the table.
1239The column headers may be omitted, provided a dashed line is used
1240to end the table. For example:
1242 ------- ------ ---------- -------
1243 12 12 12 12
1244 123 123 123 123
1245 1 1 1 1
1246 ------- ------ ---------- -------
1248When headers are omitted, column alignments are determined on the basis
1249of the first line of the table body. So, in the tables above, the columns
1250would be right, left, center, and right aligned, respectively.
1252**Multiline tables** allow headers and table rows to span multiple lines
1253of text (but cells that span multiple columns or rows of the table are
1254not supported). Here is an example:
1256 -------------------------------------------------------------
1257 Centered Default Right Left
1258 Header Aligned Aligned Aligned
1259 ----------- ------- --------------- -------------------------
1260 First row 12.0 Example of a row that
1261 spans multiple lines.
1263 Second row 5.0 Here's another one. Note
1264 the blank line between
1265 rows.
1266 -------------------------------------------------------------
1268 Table: Here's the caption. It, too, may span
1269 multiple lines.
1271These work like simple tables, but with the following differences:
1273 - They must begin with a row of dashes, before the header text
1274 (unless the headers are omitted).
1275 - They must end with a row of dashes, then a blank line.
1276 - The rows must be separated by blank lines.
1278In multiline tables, the table parser pays attention to the widths of
1279the columns, and the writers try to reproduce these relative widths in
1280the output. So, if you find that one of the columns is too narrow in the
1281output, try widening it in the markdown source.
1283Headers may be omitted in multiline tables as well as simple tables:
1285 ----------- ------- --------------- -------------------------
1286 First row 12.0 Example of a row that
1287 spans multiple lines.
1289 Second row 5.0 Here's another one. Note
1290 the blank line between
1291 rows.
1292 -------------------------------------------------------------
1294 : Here's a multiline table without headers.
1296It is possible for a multiline table to have just one row, but the row
1297should be followed by a blank line (and then the row of dashes that ends
1298the table), or the table may be interpreted as a simple table.
1300**Grid tables** look like this:
1302 : Sample grid table.
1304 +---------------+---------------+--------------------+
1305 | Fruit | Price | Advantages |
1306 +===============+===============+====================+
1307 | Bananas | $1.34 | - built-in wrapper |
1308 | | | - bright color |
1309 +---------------+---------------+--------------------+
1310 | Oranges | $2.10 | - cures scurvy |
1311 | | | - tasty |
1312 +---------------+---------------+--------------------+
1314The row of `=`s separates the header from the table body, and can be
1315omitted for a headerless table. The cells of grid tables may contain
1316arbitrary block elements (multiple paragraphs, code blocks, lists,
1317etc.). Alignments are not supported, nor are cells that span multiple
1318columns or rows. Grid tables can be created easily using [Emacs table mode].
1320 [Emacs table mode]: http://table.sourceforge.net/
1323Title block
1324-----------
1326*Pandoc extension*.
1328If the file begins with a title block
1330 % title
1331 % author(s) (separated by semicolons)
1332 % date
1334it will be parsed as bibliographic information, not regular text. (It
1335will be used, for example, in the title of standalone LaTeX or HTML
1336output.) The block may contain just a title, a title and an author,
1337or all three elements. If you want to include an author but no
1338title, or a title and a date but no author, you need a blank line:
1341 % Author
1343 % My title
1345 % June 15, 2006
1347The title may occupy multiple lines, but continuation lines must
1348begin with leading space, thus:
1350 % My title
1351 on multiple lines
1353If a document has multiple authors, the authors may be put on
1354separate lines with leading space, or separated by semicolons, or
1355both. So, all of the following are equivalent:
1357 % Author One
1358 Author Two
1360 % Author One; Author Two
1362 % Author One;
1363 Author Two
1365The date must fit on one line.
1367All three metadata fields may contain standard inline formatting
1368(italics, links, footnotes, etc.).
1370Title blocks will always be parsed, but they will affect the output only
1371when the `--standalone` (`-s`) option is chosen. In HTML output, titles
1372will appear twice: once in the document head -- this is the title that
1373will appear at the top of the window in a browser -- and once at the
1374beginning of the document body. The title in the document head can have
1375an optional prefix attached (`--title-prefix` or `-T` option). The title
1376in the body appears as an H1 element with class "title", so it can be
1377suppressed or reformatted with CSS. If a title prefix is specified with
1378`-T` and no title block appears in the document, the title prefix will
1379be used by itself as the HTML title.
1381The man page writer extracts a title, man page section number, and
1382other header and footer information from the title line. The title
1383is assumed to be the first word on the title line, which may optionally
1384end with a (single-digit) section number in parentheses. (There should
1385be no space between the title and the parentheses.) Anything after
1386this is assumed to be additional footer and header text. A single pipe
1387character (`|`) should be used to separate the footer text from the header
1388text. Thus,
1390 % PANDOC(1)
1392will yield a man page with the title `PANDOC` and section 1.
1394 % PANDOC(1) Pandoc User Manuals
1396will also have "Pandoc User Manuals" in the footer.
1398 % PANDOC(1) Pandoc User Manuals | Version 4.0
1400will also have "Version 4.0" in the header.
1403Backslash escapes
1404-----------------
1406Except inside a code block or inline code, any punctuation or space
1407character preceded by a backslash will be treated literally, even if it
1408would normally indicate formatting. Thus, for example, if one writes
1410 *\*hello\**
1412one will get
1414 <em>*hello*</em>
1416instead of
1418 <strong>hello</strong>
1420This rule is easier to remember than standard markdown's rule,
1421which allows only the following characters to be backslash-escaped:
1423 \`*_{}[]()>#+-.!
1425(However, if the `--strict` option is supplied, the standard
1426markdown rule will be used.)
1428A backslash-escaped space is parsed as a nonbreaking space. It will
1429appear in TeX output as `~` and in HTML and XML as `\&#160;` or
1430`\&nbsp;`.
1432A backslash-escaped newline (i.e. a backslash occurring at the end of
1433a line) is parsed as a hard line break. It will appear in TeX output as
1434`\\` and in HTML as `<br />`. This is a nice alternative to
1435markdown's "invisible" way of indicating hard line breaks using
1436two trailing spaces on a line.
1438Backslash escapes do not work in verbatim contexts.
1440Smart punctuation
1441-----------------
1443If the `--smart` option is specified, pandoc will produce typographically
1444correct output, converting straight quotes to curly quotes, `---` and `--`
1445to Em-dashes, and `...` to ellipses. Nonbreaking spaces are inserted after
1446certain abbreviations, such as "Mr."
1448Note: if your LaTeX template uses the `csquotes` package, pandoc will
1449detect automatically this and use `\enquote{...}` for quoted text.
1451Inline formatting
1452-----------------
1454### Emphasis ###
1456To *emphasize* some text, surround it with `*`s or `_`, like this:
1458 This text is _emphasized with underscores_, and this
1459 is *emphasized with asterisks*.
1461Double `*` or `_` produces **strong emphasis**:
1463 This is **strong emphasis** and __with underscores__.
1465A `*` or `_` character surrounded by spaces, or backslash-escaped,
1466will not trigger emphasis:
1468 This is * not emphasized *, and \*neither is this\*.
1470Because `_` is sometimes used inside words and identifiers,
1471pandoc does not interpret a `_` surrounded by alphanumeric
1472characters as an emphasis marker. If you want to emphasize
1473just part of a word, use `*`:
1475 feas*ible*, not feas*able*.
1478### Strikeout ###
1480*Pandoc extension*.
1482To strikeout a section of text with a horizontal line, begin and end it
1483with `~~`. Thus, for example,
1485 This ~~is deleted text.~~
1488### Superscripts and subscripts ###
1490*Pandoc extension*.
1492Superscripts may be written by surrounding the superscripted text by `^`
1493characters; subscripts may be written by surrounding the subscripted
1494text by `~` characters. Thus, for example,
1496 H~2~O is a liquid. 2^10^ is 1024.
1498If the superscripted or subscripted text contains spaces, these spaces
1499must be escaped with backslashes. (This is to prevent accidental
1500superscripting and subscripting through the ordinary use of `~` and `^`.)
1501Thus, if you want the letter P with 'a cat' in subscripts, use
1502`P~a\ cat~`, not `P~a cat~`.
1505### Verbatim ###
1507To make a short span of text verbatim, put it inside backticks:
1509 What is the difference between `>>=` and `>>`?
1511If the verbatim text includes a backtick, use double backticks:
1513 Here is a literal backtick `` ` ``.
1515(The spaces after the opening backticks and before the closing
1516backticks will be ignored.)
1518The general rule is that a verbatim span starts with a string
1519of consecutive backticks (optionally followed by a space)
1520and ends with a string of the same number of backticks (optionally
1521preceded by a space).
1523Note that backslash-escapes (and other markdown constructs) do not
1524work in verbatim contexts:
1526 This is a backslash followed by an asterisk: `\*`.
1529Math
1530----
1532*Pandoc extension*.
1534Anything between two `$` characters will be treated as TeX math. The
1535opening `$` must have a character immediately to its right, while the
1536closing `$` must have a character immediately to its left. Thus,
1537`$20,000 and $30,000` won't parse as math. If for some reason
1538you need to enclose text in literal `$` characters, backslash-escape
1539them and they won't be treated as math delimiters.
1541TeX math will be printed in all output formats. How it is rendered
1542depends on the output format:
1544Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt
1545 ~ It will appear verbatim between `$` characters.
1547reStructuredText
1548 ~ It will be rendered using an interpreted text role `:math:`, as described
1549 [here](http://www.american.edu/econ/itex2mml/mathhack.rst).
1551AsciiDoc
1552 ~ It will be rendered as `latexmath:[...]`.
1554Texinfo
1555 ~ It will be rendered inside a `@math` command.
1557groff man
1558 ~ It will be rendered verbatim without `$`'s.
1560MediaWiki
1561 ~ It will be rendered inside `<math>` tags.
1563Textile
1564 ~ It will be rendered inside `<span class="math">` tags.
1566RTF, DocBook, OpenDocument, ODT
1567 ~ It will be rendered, if possible, using unicode characters,
1568 and will otherwise appear verbatim.
1570HTML, Slidy, DZSlides, S5, EPUB
1571 ~ The way math is rendered in HTML will depend on the
1572 command-line options selected:
1574 1. The default is to render TeX math as far as possible using unicode
1575 characters, as with RTF, DocBook, and OpenDocument output. Formulas
1576 are put inside a `span` with `class="math"`, so that they may be
1577 styled differently from the surrounding text if needed.
1579 2. If the `--latexmathml` option is used, TeX math will be displayed
1580 between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
1581 The [LaTeXMathML] script will be used to render it as formulas.
1582 (This trick does not work in all browsers, but it works in Firefox.
1583 In browsers that do not support LaTeXMathML, TeX math will appear
1584 verbatim between $ characters.)
1586 3. If the `--jsmath` option is used, TeX math will be put inside
1587 `<span>` tags (for inline math) or `<div>` tags (for display math)
1588 with class `math`. The [jsMath] script will be used to render
1589 it.
1591 4. If the `--mimetex` option is used, the [mimeTeX] CGI script will
1592 be called to generate images for each TeX formula. This should
1593 work in all browsers. The `--mimetex` option takes an optional URL
1594 as argument. If no URL is specified, it will be assumed that the
1595 mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
1597 5. If the `--gladtex` option is used, TeX formulas will be enclosed
1598 in `<eq>` tags in the HTML output. The resulting `htex` file may then
1599 be processed by [gladTeX], which will produce image files for each
1600 formula and an `html` file with links to these images. So, the
1601 procedure is:
1603 pandoc -s --gladtex myfile.txt -o myfile.htex
1604 gladtex -d myfile-images myfile.htex
1605 # produces myfile.html and images in myfile-images
1607 6. If the `--webtex` option is used, TeX formulas will be converted
1608 to `<img>` tags that link to an external script that converts
1609 formulas to images. The formula will be URL-encoded and concatenated
1610 with the URL provided. If no URL is specified, the Google Chart
1611 API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).
1614Raw HTML
1615--------
1617Markdown allows you to insert raw HTML (or DocBook) anywhere in a document
1618(except verbatim contexts, where `<`, `>`, and `&` are interpreted
1619literally).
1621The raw HTML is passed through unchanged in HTML, S5, Slidy, DZSlides, EPUB,
1622Markdown, and Textile output, and suppressed in other formats.
1624*Pandoc extension*.
1626Standard markdown allows you to include HTML "blocks": blocks
1627of HTML between balanced tags that are separated from the surrounding text
1628with blank lines, and start and end at the left margin. Within
1629these blocks, everything is interpreted as HTML, not markdown;
1630so (for example), `*` does not signify emphasis.
1632Pandoc behaves this way when `--strict` is specified; but by default,
1633pandoc interprets material between HTML block tags as markdown.
1634Thus, for example, Pandoc will turn
1636 <table>
1637 <tr>
1638 <td>*one*</td>
1639 <td>[a link](http://google.com)</td>
1640 </tr>
1641 </table>
1643into
1645 <table>
1646 <tr>
1647 <td><em>one</em></td>
1648 <td><a href="http://google.com">a link</a></td>
1649 </tr>
1650 </table>
1652whereas `Markdown.pl` will preserve it as is.
1654There is one exception to this rule: text between `<script>` and
1655`<style>` tags is not interpreted as markdown.
1657This departure from standard markdown should make it easier to mix
1658markdown with HTML block elements. For example, one can surround
1659a block of markdown text with `<div>` tags without preventing it
1660from being interpreted as markdown.
1662Raw TeX
1663-------
1665*Pandoc extension*.
1667In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be
1668included in a document. Inline TeX commands will be preserved and passed
1669unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use
1670LaTeX to include BibTeX citations:
1672 This result was proved in \cite{jones.1967}.
1674Note that in LaTeX environments, like
1676 \begin{tabular}{|l|l|}\hline
1677 Age & Frequency \\ \hline
1678 18--25 & 15 \\
1679 26--35 & 33 \\
1680 36--45 & 22 \\ \hline
1681 \end{tabular}
1683the material between the begin and end tags will be interpreted as raw
1684LaTeX, not as markdown.
1686Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
1687and ConTeXt.
1689### Macros ###
1691For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and
1692`\renewcommand` definitions and apply the resulting macros to all LaTeX
1693math. So, for example, the following will work in all output formats,
1694not just LaTeX:
1696 \newcommand{\tuple}[1]{\langle #1 \rangle}
1698 $\tuple{a, b, c}$
1700In LaTeX output, the `\newcommand` definition will simply be passed
1701unchanged to the output.
1704Links
1705-----
1707Markdown allows links to be specified in several ways.
1709### Automatic links ###
1711If you enclose a URL or email address in pointy brackets, it
1712will become a link:
1714 <http://google.com>
1715 <sam@green.eggs.ham>
1718### Inline links ###
1720An inline link consists of the link text in square brackets,
1721followed by the URL in parentheses. (Optionally, the URL can
1722be followed by a link title, in quotes.)
1724 This is an [inline link](/url), and here's [one with
1725 a title](http://fsf.org "click here for a good time!").
1727There can be no space between the bracketed part and the parenthesized part.
1728The link text can contain formatting (such as emphasis), but the title cannot.
1731### Reference links ###
1733An *explicit* reference link has two parts, the link itself and the link
1734definition, which may occur elsewhere in the document (either
1735before or after the link).
1737The link consists of link text in square brackets, followed by a label in
1738square brackets. (There can be space between the two.) The link definition
1739must begin at the left margin or indented no more than three spaces. It
1740consists of the bracketed label, followed by a colon and a space, followed by
1741the URL, and optionally (after a space) a link title either in quotes or in
1742parentheses.
1744Here are some examples:
1746 [my label 1]: /foo/bar.html "My title, optional"
1747 [my label 2]: /foo
1748 [my label 3]: http://fsf.org (The free software foundation)
1749 [my label 4]: /bar#special 'A title in single quotes'
1751The URL may optionally be surrounded by angle brackets:
1753 [my label 5]: <http://foo.bar.baz>
1755The title may go on the next line:
1757 [my label 3]: http://fsf.org
1758 "The free software foundation"
1760Note that link labels are not case sensitive. So, this will work:
1762 Here is [my link][FOO]
1764 [Foo]: /bar/baz
1766In an *implicit* reference link, the second pair of brackets is
1767empty, or omitted entirely:
1769 See [my website][], or [my website].
1771 [my website]: http://foo.bar.baz
1774Images
1775------
1777A link immediately preceded by a `!` will be treated as an image.
1778The link text will be used as the image's alt text:
1780 ![la lune](lalune.jpg "Voyage to the moon")
1782 ![movie reel]
1784 [movie reel]: movie.gif
1786### Pictures with captions ###
1788*Pandoc extension*.
1790An image occurring by itself in a paragraph will be rendered as
1791a figure with a caption.[^5] (In LaTeX, a figure environment will be
1792used; in HTML, the image will be placed in a `div` with class
1793`figure`, together with a caption in a `p` with class `caption`.)
1794The image's alt text will be used as the caption.
1796 ![This is the caption](/url/of/image.png)
1798[^5]: This feature is not yet implemented for RTF, OpenDocument, or
1799 ODT. In those formats, you'll just get an image in a paragraph by
1800 itself, with no caption.
1802If you just want a regular inline image, just make sure it is not
1803the only thing in the paragraph. One way to do this is to insert a
1804nonbreaking space after the image:
1806 ![This image won't be a figure](/url/of/image.png)\
1809Footnotes
1810---------
1812*Pandoc extension*.
1814Pandoc's markdown allows footnotes, using the following syntax:
1816 Here is a footnote reference,[^1] and another.[^longnote]
1818 [^1]: Here is the footnote.
1820 [^longnote]: Here's one with multiple blocks.
1822 Subsequent paragraphs are indented to show that they
1823 belong to the previous footnote.
1825 { some.code }
1827 The whole paragraph can be indented, or just the first
1828 line. In this way, multi-paragraph footnotes work like
1829 multi-paragraph list items.
1831 This paragraph won't be part of the note, because it
1832 isn't indented.
1834The identifiers in footnote references may not contain spaces, tabs,
1835or newlines. These identifiers are used only to correlate the
1836footnote reference with the note itself; in the output, footnotes
1837will be numbered sequentially.
1839The footnotes themselves need not be placed at the end of the
1840document. They may appear anywhere except inside other block elements
1841(lists, block quotes, tables, etc.).
1843Inline footnotes are also allowed (though, unlike regular notes,
1844they cannot contain multiple paragraphs). The syntax is as follows:
1846 Here is an inline note.^[Inlines notes are easier to write, since
1847 you don't have to pick an identifier and move down to type the
1848 note.]
1850Inline and regular footnotes may be mixed freely.
1853Citations
1854---------
1856*Pandoc extension*.
1858Pandoc can automatically generate citations and a bibliography in a number of
1859styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature,
1860you will need a bibliographic database in one of the following formats:
1862 Format File extension
1863 ------------ --------------
1864 MODS .mods
1865 BibTeX/BibLaTeX .bib
1866 RIS .ris
1867 EndNote .enl
1868 EndNote XML .xml
1869 ISI .wos
1870 MEDLINE .medline
1871 Copac .copac
1872 JSON citeproc .json
1874You will need to specify the bibliography file using the `--bibliography`
1875command-line option (which may be repeated if you have several
1876bibliographies).
1878By default, pandoc will use a Chicago author-date format for citations
1879and references. To use another style, you will need to use the
1880`--csl` option to specify a [CSL] 1.0 style file. A primer on
1881creating and modifying CSL styles can be found at
1882<http://citationstyles.org/downloads/primer.html>.
1883A repository of CSL styles can be found at
1884<https://github.com/citation-style-language/styles>.
1885See also <http://zotero.org/styles> for easy browsing.
1887Citations go inside square brackets and are separated by semicolons.
1888Each citation must have a key, composed of '@' + the citation
1889identifier from the database, and may optionally have a prefix,
1890a locator, and a suffix. Here are some examples:
1892 Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].
1894 Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].
1896 Blah blah [@smith04; @doe99].
1898A minus sign (`-`) before the `@` will suppress mention of
1899the author in the citation. This can be useful when the
1900author is already mentioned in the text:
1902 Smith says blah [-@smith04].
1904You can also write an in-text citation, as follows:
1906 @smith04 says blah.
1908 @smith04 [p. 33] says blah.
1910If the style calls for a list of works cited, it will be placed
1911at the end of the document. Normally, you will want to end your
1912document with an appropriate header:
1914 last paragraph...
1916 # References
1918The bibliography will be inserted after this header.
1921Producing slide shows with Pandoc
1922=================================
1924You can use Pandoc to produce an HTML + javascript slide presentation
1925that can be viewed via a web browser. There are three ways to do this,
1926using [S5], [DZSlides], or [Slidy]. You can also produce a PDF slide
1927show using [LaTeX beamer]: just pass the `--beamer` option to
1928`markdown2pdf`.
1930Here's the markdown source for a simple slide show, `eating.txt`:
1932 % Eating Habits
1933 % John Doe
1934 % March 22, 2005
1936 # In the morning
1938 - Eat eggs
1939 - Drink coffee
1941 # In the evening
1943 - Eat spaghetti
1944 - Drink wine
1946 --------------------------
1948 ![picture of spaghetti](images/spaghetti.jpg)
1950To produce the slide show, simply type
1952 pandoc -w s5 -s eating.txt > eating.html
1954for S5, or
1956 pandoc -w slidy -s eating.txt > eating.html
1958for Slidy, or
1960 pandoc -w dzslides -s eating.txt > eating.html
1962for DZSlides.
1964A title page is constructed automatically from the document's title
1965block. Each level-one header and horizontal rule begins a new slide.
1966(If beamer is used, all headers begin a new slide.)
1968For Slidy and S5, the file produced by pandoc with the `-s/--standalone`
1969option embeds a link to javascripts and CSS files, which are assumed to
1970be available at the relative path `s5/default` (for S5) or at the Slidy
1971website at `w3.org` (for Slidy). (These paths can be changed by setting
1972the `slidy-url` or `s5-url` variables; see `--variable`, above.) For DZSlides,
1973the (relatively short) javascript and css are included in the file by default.
1975You can change the style of the slides by putting customized CSS files
1976in `$DATADIR/s5/default` (for S5) or `$DATADIR/slidy` (for Slidy),
1977where `$DATADIR` is the user data directory (see `--data-dir`, above).
1978The originals may be found in pandoc's system data directory (generally
1979`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any
1980files it does not find in the user data directory.
1982The `--self-contained` option can be used to produce a single file that
1983contains all of the data necessary to display the slide show, including
1984linked scripts, stylesheets, images, and videos.
1986Incremental lists
1987-----------------
1989By default, these writers produces lists that display "all at once."
1990If you want your lists to display incrementally (one item at a time),
1991use the `-i` option. If you want a particular list to depart from the
1992default (that is, to display incrementally without the `-i` option and
1993all at once with the `-i` option), put it in a block quote:
1995 > - Eat spaghetti
1996 > - Drink wine
1998In this way incremental and nonincremental lists can be mixed in
1999a single document.
2001Literate Haskell support
2002========================
2004If you append `+lhs` to an appropriate input or output format (`markdown`,
2005`rst`, or `latex` for input or output; `html` or `html5` for output only),
2006pandoc will treat the document as literate Haskell source. This means that
2008 - In markdown input, "bird track" sections will be parsed as Haskell
2009 code rather than block quotations. Text between `\begin{code}`
2010 and `\end{code}` will also be treated as Haskell code.
2012 - In markdown output, code blocks with class `haskell` will be
2013 rendered using bird tracks, and block quotations will be
2014 indented one space, so they will not be treated as Haskell code.
2015 In addition, headers will be rendered setext-style (with underlines)
2016 rather than atx-style (with '#' characters). (This is because ghc
2017 treats '#' characters in column 1 as introducing line numbers.)
2019 - In restructured text input, "bird track" sections will be parsed
2020 as Haskell code.
2022 - In restructured text output, code blocks with class `haskell` will
2023 be rendered using bird tracks.
2025 - In LaTeX input, text in `code` environments will be parsed as
2026 Haskell code.
2028 - In LaTeX output, code blocks with class `haskell` will be rendered
2029 inside `code` environments.
2031 - In HTML output, code blocks with class `haskell` will be rendered
2032 with class `literatehaskell` and bird tracks.
2034Examples:
2036 pandoc -f markdown+lhs -t html
2038reads literate Haskell source formatted with markdown conventions and writes
2039ordinary HTML (without bird tracks).
2041 pandoc -f markdown+lhs -t html+lhs
2043writes HTML with the Haskell code in bird tracks, so it can be copied
2044and pasted as literate Haskell source.
2046Authors
2047=======
2049© 2006-2011 John MacFarlane (jgm at berkeley dot edu). Released under the
2050[GPL], version 2 or greater. This software carries no warranty of
2051any kind. (See COPYRIGHT for full copyright and warranty notices.)
2052Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,
2053Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,
2054Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton,
2055Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner, qerub,
2056Christopher Sawicki, Kelsey Hightower.
2058[markdown]: http://daringfireball.net/projects/markdown/
2059[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
2060[S5]: http://meyerweb.com/eric/tools/s5/
2061[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
2062[HTML]: http://www.w3.org/TR/html40/
2063[HTML 5]: http://www.w3.org/TR/html5/
2064[XHTML]: http://www.w3.org/TR/xhtml1/
2065[LaTeX]: http://www.latex-project.org/
2066[LaTeX beamer]: http://www.tex.ac.uk/CTAN/macros/latex/contrib/beamer
2067[ConTeXt]: http://www.pragma-ade.nl/
2068[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
2069[DocBook XML]: http://www.docbook.org/
2070[OpenDocument XML]: http://opendocument.xml.org/
2071[ODT]: http://en.wikipedia.org/wiki/OpenDocument
2072[Textile]: http://redcloth.org/textile
2073[MediaWiki markup]: http://www.mediawiki.org/wiki/Help:Formatting
2074[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html
2075[Haskell]: http://www.haskell.org/
2076[GNU Texinfo]: http://www.gnu.org/software/texinfo/
2077[Emacs Org-Mode]: http://orgmode.org
2078[AsciiDoc]: http://www.methods.co.nz/asciidoc/
2079[EPUB]: http://www.idpf.org/
2080[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
2081[DZSlides]: http://paulrouget.com/dzslides/
2082[ISO 8601 format]: http://www.w3.org/TR/NOTE-datetime