git.iko.soy/typeable/pandoc
on 38fbfed help sign in
2058 lines 72 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[HTML], [LaTeX], [ConTeXt], [RTF], [DocBook XML], [OpenDocument XML], [ODT],
18[GNU Texinfo], [MediaWiki markup], [EPUB], [Textile], [groff man] pages,
19[Emacs Org-Mode], [AsciiDoc], and [Slidy], [DZSlides], or [S5] HTML
20slide 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),
155 `html` (HTML), `latex` (LaTeX), `context` (ConTeXt), `man` (groff man),
156 `mediawiki` (MediaWiki markup), `textile` (Textile), `org` (Emacs
157 Org-Mode), `texinfo` (GNU Texinfo), `docbook` (DocBook XML),
158 `opendocument` (OpenDocument XML), `odt` (OpenOffice text document),
159 `epub` (EPUB book), `asciidoc` (AsciiDoc), `slidy` (Slidy HTML and
160 javascript slide show), `dzslides` (HTML5 + javascript slide show),
161 `s5` (S5 HTML and javascript slide show), or `rtf` (rich text
162 format). Note that `odt` and `epub` output will not be directed to
163 *stdout*; an output filename must be specified using the `-o/--output`
164 option. If `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`,
165 the output will be rendered as literate Haskell source:
166 see [Literate Haskell support](#literate-haskell-support),
167 below.
169`-s`, `--standalone`
170: Produce output with an appropriate header and footer (e.g. a
171 standalone HTML, LaTeX, or RTF file, not a fragment).
173`-o` *FILE*, `--output=`*FILE*
174: Write output to *FILE* instead of *stdout*. If *FILE* is
175 `-`, output will go to *stdout*. (Exception: if the output
176 format is `odt` or `epub`, output to stdout is disabled.)
178`-p`, `--preserve-tabs`
179: Preserve tabs instead of converting them to spaces (the default).
181`--tab-stop=`*NUMBER*
182: Specify the number of spaces per tab (default is 4).
184`--strict`
185: Use strict markdown syntax, with no pandoc extensions or variants.
186 When the input format is HTML, this means that constructs that have no
187 equivalents in standard markdown (e.g. definition lists or strikeout
188 text) will be parsed as raw HTML.
190`--normalize`
191: Normalize the document after reading: merge adjacent
192 `Str` or `Emph` elements, for example, and remove repeated `Space`s.
194`--reference-links`
195: Use reference-style links, rather than inline links, in writing markdown
196 or reStructuredText. By default inline links are used.
198`-R`, `--parse-raw`
199: Parse untranslatable HTML codes and LaTeX environments as raw HTML
200 or LaTeX, instead of ignoring them. Affects only HTML and LaTeX
201 input. Raw HTML can be printed in markdown, reStructuredText, HTML, Slidy,
202 DZSlides, and S5 output; raw LaTeX can be printed in markdown,
203 reStructuredText, LaTeX, and ConTeXt output. The default is for the
204 readers to omit untranslatable HTML codes and LaTeX environments.
205 (The LaTeX reader does pass through untranslatable LaTeX *commands*,
206 even if `-R` is not specified.)
208`-S`, `--smart`
209: Produce typographically correct output, converting straight quotes
210 to curly quotes, `---` and `--` to dashes, and `...` to ellipses.
211 Nonbreaking spaces are inserted after certain abbreviations, such
212 as "Mr." (Note: This option is significant only when the input format is
213 `markdown` or `textile`. It is selected automatically when the input
214 format is `textile` or the output format is `latex` or `context`.)
216`-5`, `--html5`
217: Produce HTML5 instead of HTML4. This option has no effect for writers
218 other than `html`.
220`-m` [*URL*], `--latexmathml`[=*URL*]
221: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.
222 To insert a link to a local copy of the `LaTeXMathML.js` script,
223 provide a *URL*. If no *URL* is provided, the contents of the
224 script will be inserted directly into the HTML header, preserving
225 portability at the price of efficiency. If you plan to use math on
226 several pages, it is much better to link to a copy of the script,
227 so it can be cached.
229`--mathml`[=*URL*]
230: Convert TeX math to MathML. In standalone mode, a small javascript
231 (or a link to such a script if a *URL* is supplied) will be inserted that
232 allows the MathML to be viewed on some browsers.
234`--jsmath`[=*URL*]
235: Use [jsMath] to display embedded TeX math in HTML output.
236 The *URL* should point to the jsMath load script (e.g.
237 `jsMath/easy/load.js`); if provided, it will be linked to in
238 the header of standalone HTML documents. If a *URL* is not provided,
239 no link to the jsMath load script will be inserted; it is then
240 up to the author to provide such a link in the HTML template.
242`--mathjax`[=*URL*]
243: Use [MathJax] to display embedded TeX math in HTML output.
244 The *URL* should point to the `MathJax.js` load script.
245 If a *URL* is not provided, a link to the MathJax CDN will
246 be inserted.
248`--gladtex`
249: Enclose TeX math in `<eq>` tags in HTML output. These can then
250 be processed by [gladTeX] to produce links to images of the typeset
251 formulas.
253`--mimetex`[=*URL*]
254: Render TeX math using the [mimeTeX] CGI script. If *URL* is not
255 specified, it is assumed that the script is at `/cgi-bin/mimetex.cgi`.
257`--webtex`[=*URL*]
258: Render TeX formulas using an external script that converts TeX
259 formulas to images. The formula will be concatenated with the URL
260 provided. If *URL* is not specified, the Google Chart API will be used.
262`-i`, `--incremental`
263: Make list items in Slidy, DZSlides or S5 display incrementally (one by one).
264 The default is for lists to be displayed all at once.
266`--self-contained`
267: Produce a standalone HTML file with no external dependencies, using
268 `data:` URIs to incorporate the contents of linked scripts, stylesheets,
269 images, and videos. The resulting file should be "self-contained,"
270 in the sense that it needs no external files and no net access to be
271 displayed properly by a browser. This option works only with HTML output
272 formats, including `html`, `html+lhs`, `s5`, `slidy`, and `dzslides`.
273 Scripts, images, and stylesheets at absolute URLs will be downloaded;
274 those at relative URLs will be sought first relative to the working
275 directory, then relative to the user data directory (see `--data-dir`),
276 and finally relative to pandoc's default data directory.
278`--offline`
279: Deprecated synonym for `--self-contained`.
281`--chapters`
282: Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook
283 output. When the LaTeX template uses the report, book, or
284 memoir class, this option is implied.
286`-N`, `--number-sections`
287: Number section headings in LaTeX, ConTeXt, or HTML output.
288 By default, sections are not numbered.
290`--listings`
291: Use listings package for LaTeX code blocks
293`--section-divs`
294: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),
295 and attach identifiers to the enclosing `<div>` (or `<section>`)
296 rather than the header itself.
297 See [Section identifiers](#header-identifiers-in-html), below.
299`--no-wrap`
300: Disable text wrapping in output. By default, text is wrapped
301 appropriately for the output format.
303`--columns`=*NUMBER*
304: Specify length of lines in characters (for text wrapping).
306`--ascii`
307: Use only ascii characters in output. Currently supported only
308 for HTML output (which uses numerical entities instead of
309 UTF-8 when this option is selected).
311`--email-obfuscation=`*none|javascript|references*
312: Specify a method for obfuscating `mailto:` links in HTML documents.
313 *none* leaves `mailto:` links as they are. *javascript* obfuscates
314 them using javascript. *references* obfuscates them by printing their
315 letters as decimal or hexadecimal character references.
316 If `--strict` is specified, *references* is used regardless of the
317 presence of this option.
319`--id-prefix`=*STRING*
320: Specify a prefix to be added to all automatically generated identifiers
321 in HTML output. This is useful for preventing duplicate identifiers
322 when generating fragments to be included in other pages.
324`--indented-code-classes=`*CLASSES*
325: Specify classes to use for indented code blocks--for example,
326 `perl,numberLines` or `haskell`. Multiple classes may be separated
327 by spaces or commas.
329`--toc`, `--table-of-contents`
330: Include an automatically generated table of contents (or, in
331 the case of `latex`, `context`, and `rst`, an instruction to create
332 one) in the output document. This option has no effect on `man`,
333 `docbook`, `slidy`, or `s5` output.
335`--base-header-level=`*NUMBER*
336: Specify the base level for headers (defaults to 1).
338`--template=`*FILE*
339: Use *FILE* as a custom template for the generated document. Implies
340 `--standalone`. See [Templates](#templates) below for a description
341 of template syntax. If no extension is specified, an extension
342 corresponding to the writer will be added, so that `--template=special`
343 looks for `special.html` for HTML output. If the template is not
344 found, pandoc will search for it in the user data directory
345 (see `--data-dir`). If this option is not used, a default
346 template appropriate for the output format will be used (see
347 `-D/--print-default-template`).
349`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
350: Set the template variable *KEY* to the value *VAL* when rendering the
351 document in standalone mode. This is generally only useful when the
352 `--template` option is used to specify a custom template, since
353 pandoc automatically sets the variables used in the default
354 templates.
356`-c` *URL*, `--css=`*URL*
357: Link to a CSS style sheet.
359`-H` *FILE*, `--include-in-header=`*FILE*
360: Include contents of *FILE*, verbatim, at the end of the header.
361 This can be used, for example, to include special
362 CSS or javascript in HTML documents. This option can be used
363 repeatedly to include multiple files in the header. They will be
364 included in the order specified. Implies `--standalone`.
366`-B` *FILE*, `--include-before-body=`*FILE*
367: Include contents of *FILE*, verbatim, at the beginning of the
368 document body (e.g. after the `<body>` tag in HTML, or the
369 `\begin{document}` command in LaTeX). This can be used to include
370 navigation bars or banners in HTML documents. This option can be
371 used repeatedly to include multiple files. They will be included in
372 the order specified. Implies `--standalone`.
374`-A` *FILE*, `--include-after-body=`*FILE*
375: Include contents of *FILE*, verbatim, at the end of the document
376 body (before the `</body>` tag in HTML, or the
377 `\end{document}` command in LaTeX). This option can be be used
378 repeatedly to include multiple files. They will be included in the
379 order specified. Implies `--standalone`.
381`--reference-odt=`*FILE*
382: Use the specified file as a style reference in producing an ODT.
383 For best results, the reference ODT should be a modified version
384 of an ODT produced using pandoc. The contents of the reference ODT
385 are ignored, but its stylesheets are used in the new ODT. If no
386 reference ODT is specified on the command line, pandoc will look
387 for a file `reference.odt` in the user data directory (see
388 `--data-dir`). If this is not found either, sensible defaults will be
389 used.
391`--epub-stylesheet=`*FILE*
392: Use the specified CSS file to style the EPUB. If no stylesheet
393 is specified, pandoc will look for a file `epub.css` in the
394 user data directory (see `--data-dir`, below). If it is not
395 found there, sensible defaults will be used.
397`--epub-cover-image=`*FILE*
398: Use the specified image as the EPUB cover. It is recommended
399 that the image be less than 1000px in width and height.
401`--epub-metadata=`*FILE*
402: Look in the specified XML file for metadata for the EPUB.
403 The file should contain a series of Dublin Core elements,
404 as documented at <http://dublincore.org/documents/dces/>.
405 For example:
407 <dc:rights>Creative Commons</dc:rights>
408 <dc:language>es-AR</dc:language>
410 By default, pandoc will include the following metadata elements:
411 `<dc:title>` (from the document title), `<dc:creator>` (from the
412 document authors), `<dc:language>` (from the locale), and
413 `<dc:identifier id="BookId">` (a randomly generated UUID). Any of
414 these may be overridden by elements in the metadata file.
416`-D` *FORMAT*, `--print-default-template=`*FORMAT*
417: Print the default template for an output *FORMAT*. (See `-t`
418 for a list of possible *FORMAT*s.)
420`-T` *STRING*, `--title-prefix=`*STRING*
421: Specify *STRING* as a prefix at the beginning of the title
422 that appears in the HTML header (but not in the title as it
423 appears at the beginning of the HTML body). Implies
424 `--standalone`.
426`--bibliography=`*FILE*
427: Specify bibliography database to be used in resolving
428 citations. The database type will be determined from the
429 extension of *FILE*, which may be `.mods` (MODS format),
430 `.bib` (BibTeX/BibLaTeX format),
431 `.ris` (RIS format), `.enl` (EndNote format),
432 `.xml` (EndNote XML format), `.wos` (ISI format),
433 `.medline` (MEDLINE format), `.copac` (Copac format),
434 or `.json` (citeproc JSON). If you want to use multiple
435 bibliographies, just use this option repeatedly.
437`--csl=`*FILE*
438: Specify [CSL] style to be used in formatting citations and
439 the bibliography. If *FILE* is not found, pandoc will look
440 for it in
442 $HOME/.csl
444 in unix and
446 C:\Documents And Settings\USERNAME\Application Data\csl
448 in Windows. If the `--csl` option is not specified, pandoc
449 will use a default style: either `default.csl` in the
450 user data directory (see `--data-dir`), or, if that is
451 not present, the Chicago author-date style.
453`--citation-abbreviations=`*FILE*
454: Specify a file containing abbreviations for journal titles and
455 other bibliographic fields (indicated by setting `form="short"`
456 in the CSL node for the field). The format is described at
457 <http://citationstylist.org/2011/10/19/abbreviations-for-zotero-test-release/>.
458 Here is a short example:
460 { "default": {
461 "container-title": {
462 "Lloyd's Law Reports": "Lloyd's Rep",
463 "Estates Gazette": "EG",
464 "Scots Law Times": "SLT"
465 }
466 }
467 }
469`--natbib`
470: Use natbib for citations in LaTeX output.
472`--biblatex`
473: Use biblatex for citations in LaTeX output.
475`--data-dir=`*DIRECTORY*
476: Specify the user data directory to search for pandoc data files.
477 If this option is not specified, the default user data directory
478 will be used:
480 $HOME/.pandoc
482 in unix and
484 C:\Documents And Settings\USERNAME\Application Data\pandoc
486 in Windows. A `reference.odt`, `epub.css`, `templates` directory,
487 or `s5` directory placed in this directory will override pandoc's
488 normal defaults.
490`--dump-args`
491: Print information about command-line arguments to *stdout*, then exit.
492 This option is intended primarily for use in wrapper scripts.
493 The first line of output contains the name of the output file specified
494 with the `-o` option, or `-` (for *stdout*) if no output file was
495 specified. The remaining lines contain the command-line arguments,
496 one per line, in the order they appear. These do not include regular
497 Pandoc options and their arguments, but do include any options appearing
498 after a `--` separator at the end of the line.
500`--ignore-args`
501: Ignore command-line arguments (for use in wrapper scripts).
502 Regular Pandoc options are not ignored. Thus, for example,
504 pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
506 is equivalent to
508 pandoc -o foo.html -s
510`-v`, `--version`
511: Print version.
513`-h`, `--help`
514: Show usage message.
516[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/
517[jsMath]: http://www.math.union.edu/~dpvc/jsmath/
518[MathJax]: http://www.mathjax.org/
519[gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html
520[mimeTeX]: http://www.forkosh.com/mimetex.html
521[CSL]: http://CitationStyles.org
523Templates
524=========
526When the `-s/--standalone` option is used, pandoc uses a template to
527add header and footer material that is needed for a self-standing
528document. To see the default template that is used, just type
530 pandoc -D FORMAT
532where `FORMAT` is the name of the output format. A custom template
533can be specified using the `--template` option. You can also override
534the system default templates for a given output format `FORMAT`
535by putting a file `templates/default.FORMAT` in the user data
536directory (see `--data-dir`, above).
538Templates may contain *variables*. Variable names are sequences of
539alphanumerics, `-`, and `_`, starting with a letter. A variable name
540surrounded by `$` signs will be replaced by its value. For example,
541the string `$title$` in
543 <title>$title$</title>
545will be replaced by the document title.
547To write a literal `$` in a template, use `$$`.
549Some variables are set automatically by pandoc. These vary somewhat
550depending on the output format, but include:
552`header-includes`
553: contents specified by `-H/--include-in-header` (may have multiple
554 values)
555`toc`
556: non-null value if `--toc/--table-of-contents` was specified
557`include-before`
558: contents specified by `-B/--include-before-body` (may have
559 multiple values)
560`include-after`
561: contents specified by `-A/--include-after-body` (may have
562 multiple values)
563`body`
564: body of document
565`title`
566: title of document, as specified in title block
567`author`
568: author of document, as specified in title block (may have
569 multiple values)
570`date`
571: date of document, as specified in title block
572`lang`
573: language code for HTML or LaTeX documents
574`slidy-url`
575: base URL for Slidy documents (defaults to
576 `http://www.w3.org/Talks/Tools/Slidy2`)
577`s5-url`
578: base URL for S5 documents (defaults to `ui/default`)
580Variables may be set at the command line using the `-V/--variable`
581option. This allows users to include custom variables in their
582templates.
584Templates may contain conditionals. The syntax is as follows:
586 $if(variable)$
587 X
588 $else$
589 Y
590 $endif$
592This will include `X` in the template if `variable` has a non-null
593value; otherwise it will include `Y`. `X` and `Y` are placeholders for
594any valid template text, and may include interpolated variables or other
595conditionals. The `$else$` section may be omitted.
597When variables can have multiple values (for example, `author` in
598a multi-author document), you can use the `$for$` keyword:
600 $for(author)$
601 <meta name="author" content="$author$" />
602 $endfor$
604You can optionally specify a separator to be used between
605consecutive items:
607 $for(author)$$author$$sep$, $endfor$
609If you use custom templates, you may need to revise them as pandoc
610changes. We recommend tracking the changes in the default templates,
611and modifying your custom templates accordingly. An easy way to do this
612is to fork the pandoc-templates repository
613(<http://github.com/jgm/pandoc-templates>) and merge in changes after each
614pandoc release.
616Pandoc's markdown
617=================
619Pandoc understands an extended and slightly revised version of
620John Gruber's [markdown] syntax. This document explains the syntax,
621noting differences from standard markdown. Except where noted, these
622differences can be suppressed by specifying the `--strict` command-line
623option.
625Philosophy
626----------
628Markdown is designed to be easy to write, and, even more importantly,
629easy to read:
631> A Markdown-formatted document should be publishable as-is, as plain
632> text, without looking like it's been marked up with tags or formatting
633> instructions.
634> -- [John Gruber](http://daringfireball.net/projects/markdown/syntax#philosophy)
636This principle has guided pandoc's decisions in finding syntax for
637tables, footnotes, and other extensions.
639There is, however, one respect in which pandoc's aims are different
640from the original aims of markdown. Whereas markdown was originally
641designed with HTML generation in mind, pandoc is designed for multiple
642output formats. Thus, while pandoc allows the embedding of raw HTML,
643it discourages it, and provides other, non-HTMLish ways of representing
644important document elements like definition lists, tables, mathematics, and
645footnotes.
647Paragraphs
648----------
650A paragraph is one or more lines of text followed by one or more blank line.
651Newlines are treated as spaces, so you can reflow your paragraphs as you like.
652If you need a hard line break, put two or more spaces at the end of a line,
653or type a backslash followed by a newline.
655Headers
656-------
658There are two kinds of headers, Setext and atx.
660### Setext-style headers ###
662A setext-style header is a line of text "underlined" with a row of `=` signs
663(for a level one header) of `-` signs (for a level two header):
665 A level-one header
666 ==================
668 A level-two header
669 ------------------
671The header text can contain inline formatting, such as emphasis (see
672[Inline formatting](#inline-formatting), below).
675### Atx-style headers ###
677An Atx-style header consists of one to six `#` signs and a line of
678text, optionally followed by any number of `#` signs. The number of
679`#` signs at the beginning of the line is the header level:
681 ## A level-two header
683 ### A level-three header ###
685As with setext-style headers, the header text can contain formatting:
687 # A level-one header with a [link](/url) and *emphasis*
689Standard markdown syntax does not require a blank line before a header.
690Pandoc does require this (except, of course, at the beginning of the
691document). The reason for the requirement is that it is all too easy for a
692`#` to end up at the beginning of a line by accident (perhaps through line
693wrapping). Consider, for example:
695 I like several of their flavors of ice cream:
696 #22, for example, and #5.
699### Header identifiers in HTML ###
701*Pandoc extension*.
703Each header element in pandoc's HTML output is given a unique
704identifier. This identifier is based on the text of the header. To
705derive the identifier from the header text,
707 - Remove all formatting, links, etc.
708 - Remove all punctuation, except underscores, hyphens, and periods.
709 - Replace all spaces and newlines with hyphens.
710 - Convert all alphabetic characters to lowercase.
711 - Remove everything up to the first letter (identifiers may
712 not begin with a number or punctuation mark).
713 - If nothing is left after this, use the identifier `section`.
715Thus, for example,
717 Header Identifier
718 ------------------------------- ----------------------------
719 Header identifiers in HTML `header-identifiers-in-html`
720 *Dogs*?--in *my* house? `dogs--in-my-house`
721 [HTML], [S5], or [RTF]? `html-s5-or-rtf`
722 3. Applications `applications`
723 33 `section`
725These rules should, in most cases, allow one to determine the identifier
726from the header text. The exception is when several headers have the
727same text; in this case, the first will get an identifier as described
728above; the second will get the same identifier with `-1` appended; the
729third with `-2`; and so on.
731These identifiers are used to provide link targets in the table of
732contents generated by the `--toc|--table-of-contents` option. They
733also make it easy to provide links from one section of a document to
734another. A link to this section, for example, might look like this:
736 See the section on
737 [header identifiers](#header-identifiers-in-html).
739Note, however, that this method of providing links to sections works
740only in HTML.
742If the `--section-divs` option is specified, then each section will
743be wrapped in a `div` (or a `section`, if `--html5` was specified),
744and the identifier will be attached to the enclosing `<div>`
745(or `<section>`) tag rather than the header itself. This allows entire
746sections to be manipulated using javascript or treated differently in
747CSS.
750Block quotations
751----------------
753Markdown uses email conventions for quoting blocks of text.
754A block quotation is one or more paragraphs or other block elements
755(such as lists or headers), with each line preceded by a `>` character
756and a space. (The `>` need not start at the left margin, but it should
757not be indented more than three spaces.)
759 > This is a block quote. This
760 > paragraph has two lines.
761 >
762 > 1. This is a list inside a block quote.
763 > 2. Second item.
765A "lazy" form, which requires the `>` character only on the first
766line of each block, is also allowed:
768 > This is a block quote. This
769 paragraph has two lines.
771 > 1. This is a list inside a block quote.
772 2. Second item.
774Among the block elements that can be contained in a block quote are
775other block quotes. That is, block quotes can be nested:
777 > This is a block quote.
778 >
779 > > A block quote within a block quote.
781Standard markdown syntax does not require a blank line before a block
782quote. Pandoc does require this (except, of course, at the beginning of the
783document). The reason for the requirement is that it is all too easy for a
784`>` to end up at the beginning of a line by accident (perhaps through line
785wrapping). So, unless `--strict` is used, the following does not produce
786a nested block quote in pandoc:
788 > This is a block quote.
789 >> Nested.
792Verbatim (code) blocks
793----------------------
795### Indented code blocks ###
797A block of text indented four spaces (or one tab) is treated as verbatim
798text: that is, special characters do not trigger special formatting,
799and all spaces and line breaks are preserved. For example,
801 if (a > 3) {
802 moveShip(5 * gravity, DOWN);
803 }
805The initial (four space or one tab) indentation is not considered part
806of the verbatim text, and is removed in the output.
808Note: blank lines in the verbatim text need not begin with four spaces.
811### Delimited code blocks ###
813*Pandoc extension*.
815In addition to standard indented code blocks, Pandoc supports
816*delimited* code blocks. These begin with a row of three or more
817tildes (`~`) and end with a row of tildes that must be at least
818as long as the starting row. Everything between the tilde-lines
819is treated as code. No indentation is necessary:
821 ~~~~~~~
822 if (a > 3) {
823 moveShip(5 * gravity, DOWN);
824 }
825 ~~~~~~~
827Like regular code blocks, delimited code blocks must be separated
828from surrounding text by blank lines.
830If the code itself contains a row of tildes, just use a longer
831row of tildes at the start and end:
833 ~~~~~~~~~~~~~~~~
834 ~~~~~~~~~~
835 code including tildes
836 ~~~~~~~~~~
837 ~~~~~~~~~~~~~~~~
839Optionally, you may specify the language of the code block using
840this syntax:
842 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines}
843 qsort [] = []
844 qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
845 qsort (filter (>= x) xs)
846 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
848Some output formats can use this information to do syntax highlighting.
849Currently, the only output format that uses this information is HTML.
851If pandoc has been compiled with syntax highlighting support, then the
852code block above will appear highlighted, with numbered lines. (To see
853which languages are supported, do `pandoc --version`.)
855If pandoc has not been compiled with syntax highlighting support, the
856code block above will appear as follows:
858 <pre class="haskell">
859 <code>
860 ...
861 </code>
862 </pre>
865Lists
866-----
868### Bullet lists ###
870A bullet list is a list of bulleted list items. A bulleted list
871item begins with a bullet (`*`, `+`, or `-`). Here is a simple
872example:
874 * one
875 * two
876 * three
878This will produce a "compact" list. If you want a "loose" list, in which
879each item is formatted as a paragraph, put spaces between the items:
881 * one
883 * two
885 * three
887The bullets need not be flush with the left margin; they may be
888indented one, two, or three spaces. The bullet must be followed
889by whitespace.
891List items look best if subsequent lines are flush with the first
892line (after the bullet):
894 * here is my first
895 list item.
896 * and my second.
898But markdown also allows a "lazy" format:
900 * here is my first
901 list item.
902 * and my second.
904### The four-space rule ###
906A list item may contain multiple paragraphs and other block-level
907content. However, subsequent paragraphs must be preceded by a blank line
908and indented four spaces or a tab. The list will look better if the first
909paragraph is aligned with the rest:
911 * First paragraph.
913 Continued.
915 * Second paragraph. With a code block, which must be indented
916 eight spaces:
918 { code }
920List items may include other lists. In this case the preceding blank
921line is optional. The nested list must be indented four spaces or
922one tab:
924 * fruits
925 + apples
926 - macintosh
927 - red delicious
928 + pears
929 + peaches
930 * vegetables
931 + brocolli
932 + chard
934As noted above, markdown allows you to write list items "lazily," instead of
935indenting continuation lines. However, if there are multiple paragraphs or
936other blocks in a list item, the first line of each must be indented.
938 + A lazy, lazy, list
939 item.
941 + Another one; this looks
942 bad but is legal.
944 Second paragraph of second
945 list item.
947**Note:** Although the four-space rule for continuation paragraphs
948comes from the official [markdown syntax guide], the reference implementation,
949`Markdown.pl`, does not follow it. So pandoc will give different results than
950`Markdown.pl` when authors have indented continuation paragraphs fewer than
951four spaces.
953The [markdown syntax guide] is not explicit whether the four-space
954rule applies to *all* block-level content in a list item; it only
955mentions paragraphs and code blocks. But it implies that the rule
956applies to all block-level content (including nested lists), and
957pandoc interprets it that way.
959 [markdown syntax guide]:
960 http://daringfireball.net/projects/markdown/syntax#list
962### Ordered lists ###
964Ordered lists work just like bulleted lists, except that the items
965begin with enumerators rather than bullets.
967In standard markdown, enumerators are decimal numbers followed
968by a period and a space. The numbers themselves are ignored, so
969there is no difference between this list:
971 1. one
972 2. two
973 3. three
975and this one:
977 5. one
978 7. two
979 1. three
981*Pandoc extension*.
983Unlike standard markdown, Pandoc allows ordered list items to be marked
984with uppercase and lowercase letters and roman numerals, in addition to
985arabic numerals. List markers may be enclosed in parentheses or followed by a
986single right-parentheses or period. They must be separated from the
987text that follows by at least one space, and, if the list marker is a
988capital letter with a period, by at least two spaces.[^2]
990[^2]: The point of this rule is to ensure that normal paragraphs
991 starting with people's initials, like
993 B. Russell was an English philosopher.
995 do not get treated as list items.
997 This rule will not prevent
999 (C) 2007 Joe Smith
1001 from being interpreted as a list item. In this case, a backslash
1002 escape can be used:
1004 (C\) 2007 Joe Smith
1006Pandoc also pays attention to the type of list marker used, and to the
1007starting number, and both of these are preserved where possible in the
1008output format. Thus, the following yields a list with numbers followed
1009by a single parenthesis, starting with 9, and a sublist with lowercase
1010roman numerals:
1012 9) Ninth
1013 10) Tenth
1014 11) Eleventh
1015 i. subone
1016 ii. subtwo
1017 iii. subthree
1019Note that Pandoc pays attention only to the *starting* marker in a list.
1020So, the following yields a list numbered sequentially starting from 2:
1022 (2) Two
1023 (5) Three
1024 1. Four
1025 * Five
1027If default list markers are desired, use `#.`:
1029 #. one
1030 #. two
1031 #. three
1034### Definition lists ###
1036*Pandoc extension*.
1038Pandoc supports definition lists, using a syntax inspired by
1039[PHP Markdown Extra] and [reStructuredText]:[^3]
1041 Term 1
1043 : Definition 1
1045 Term 2 with *inline markup*
1047 : Definition 2
1049 { some code, part of Definition 2 }
1051 Third paragraph of definition 2.
1053Each term must fit on one line, which may optionally be followed by
1054a blank line, and must be followed by one or more definitions.
1055A definition begins with a colon or tilde, which may be indented one
1056or two spaces. The body of the definition (including the first line,
1057aside from the colon or tilde) should be indented four spaces. A term may have
1058multiple definitions, and each definition may consist of one or more block
1059elements (paragraph, code block, list, etc.), each indented four spaces or one
1060tab stop.
1062If you leave space after the definition (as in the example above),
1063the blocks of the definitions will be considered paragraphs. In some
1064output formats, this will mean greater spacing between term/definition
1065pairs. For a compact definition list, do not leave space between the
1066definition and the next term:
1068 Term 1
1069 ~ Definition 1
1070 Term 2
1071 ~ Definition 2a
1072 ~ Definition 2b
1074[^3]: I have also been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).
1076[PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
1079### Numbered example lists ###
1081*Pandoc extension*.
1083The special list marker `@` can be used for sequentially numbered
1084examples. The first list item with a `@` marker will be numbered '1',
1085the next '2', and so on, throughout the document. The numbered examples
1086need not occur in a single list; each new list using `@` will take up
1087where the last stopped. So, for example:
1089 (@) My first example will be numbered (1).
1090 (@) My second example will be numbered (2).
1092 Explanation of examples.
1094 (@) My third example will be numbered (3).
1096Numbered examples can be labeled and referred to elsewhere in the
1097document:
1099 (@good) This is a good example.
1101 As (@good) illustrates, ...
1103The label can be any string of alphanumeric characters, underscores,
1104or hyphens.
1107### Compact and loose lists ###
1109Pandoc behaves differently from `Markdown.pl` on some "edge
1110cases" involving lists. Consider this source:
1112 + First
1113 + Second:
1114 - Fee
1115 - Fie
1116 - Foe
1118 + Third
1120Pandoc transforms this into a "compact list" (with no `<p>` tags around
1121"First", "Second", or "Third"), while markdown puts `<p>` tags around
1122"Second" and "Third" (but not "First"), because of the blank space
1123around "Third". Pandoc follows a simple rule: if the text is followed by
1124a blank line, it is treated as a paragraph. Since "Second" is followed
1125by a list, and not a blank line, it isn't treated as a paragraph. The
1126fact that the list is followed by a blank line is irrelevant. (Note:
1127Pandoc works this way even when the `--strict` option is specified. This
1128behavior is consistent with the official markdown syntax description,
1129even though it is different from that of `Markdown.pl`.)
1132### Ending a list ###
1134What if you want to put an indented code block after a list?
1136 - item one
1137 - item two
1139 { my code block }
1141Trouble! Here pandoc (like other markdown implementations) will treat
1142`{ my code block }` as the second paragraph of item two, and not as
1143a code block.
1145To "cut off" the list after item two, you can insert some non-indented
1146content, like an HTML comment, which won't produce visible output in
1147any format:
1149 - item one
1150 - item two
1152 <!-- end of list -->
1154 { my code block }
1156You can use the same trick if you want two consecutive lists instead
1157of one big list:
1159 1. one
1160 2. two
1161 3. three
1163 <!-- -->
1165 a. uno
1166 b. dos
1167 c. tres
1170Horizontal rules
1171----------------
1173A line containing a row of three or more `*`, `-`, or `_` characters
1174(optionally separated by spaces) produces a horizontal rule:
1176 * * * *
1178 ---------------
1181Tables
1182------
1184*Pandoc extension*.
1186Three kinds of tables may be used. All three kinds presuppose the use of
1187a fixed-width font, such as Courier.
1189**Simple tables** look like this:
1191 Right Left Center Default
1192 ------- ------ ---------- -------
1193 12 12 12 12
1194 123 123 123 123
1195 1 1 1 1
1197 Table: Demonstration of simple table syntax.
1199The headers and table rows must each fit on one line. Column
1200alignments are determined by the position of the header text relative
1201to the dashed line below it:[^4]
1203 - If the dashed line is flush with the header text on the right side
1204 but extends beyond it on the left, the column is right-aligned.
1205 - If the dashed line is flush with the header text on the left side
1206 but extends beyond it on the right, the column is left-aligned.
1207 - If the dashed line extends beyond the header text on both sides,
1208 the column is centered.
1209 - If the dashed line is flush with the header text on both sides,
1210 the default alignment is used (in most cases, this will be left).
1212[^4]: This scheme is due to Michel Fortin, who proposed it on the
1213 [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).
1215The table must end with a blank line, or a line of dashes followed by
1216a blank line. A caption may optionally be provided (as illustrated in
1217the example above). A caption is a paragraph beginning with the string
1218`Table:` (or just `:`), which will be stripped off. It may appear either
1219before or after the table.
1221The column headers may be omitted, provided a dashed line is used
1222to end the table. For example:
1224 ------- ------ ---------- -------
1225 12 12 12 12
1226 123 123 123 123
1227 1 1 1 1
1228 ------- ------ ---------- -------
1230When headers are omitted, column alignments are determined on the basis
1231of the first line of the table body. So, in the tables above, the columns
1232would be right, left, center, and right aligned, respectively.
1234**Multiline tables** allow headers and table rows to span multiple lines
1235of text (but cells that span multiple columns or rows of the table are
1236not supported). Here is an example:
1238 -------------------------------------------------------------
1239 Centered Default Right Left
1240 Header Aligned Aligned Aligned
1241 ----------- ------- --------------- -------------------------
1242 First row 12.0 Example of a row that
1243 spans multiple lines.
1245 Second row 5.0 Here's another one. Note
1246 the blank line between
1247 rows.
1248 -------------------------------------------------------------
1250 Table: Here's the caption. It, too, may span
1251 multiple lines.
1253These work like simple tables, but with the following differences:
1255 - They must begin with a row of dashes, before the header text
1256 (unless the headers are omitted).
1257 - They must end with a row of dashes, then a blank line.
1258 - The rows must be separated by blank lines.
1260In multiline tables, the table parser pays attention to the widths of
1261the columns, and the writers try to reproduce these relative widths in
1262the output. So, if you find that one of the columns is too narrow in the
1263output, try widening it in the markdown source.
1265Headers may be omitted in multiline tables as well as simple tables:
1267 ----------- ------- --------------- -------------------------
1268 First row 12.0 Example of a row that
1269 spans multiple lines.
1271 Second row 5.0 Here's another one. Note
1272 the blank line between
1273 rows.
1274 -------------------------------------------------------------
1276 : Here's a multiline table without headers.
1278It is possible for a multiline table to have just one row, but the row
1279should be followed by a blank line (and then the row of dashes that ends
1280the table), or the table may be interpreted as a simple table.
1282**Grid tables** look like this:
1284 : Sample grid table.
1286 +---------------+---------------+--------------------+
1287 | Fruit | Price | Advantages |
1288 +===============+===============+====================+
1289 | Bananas | $1.34 | - built-in wrapper |
1290 | | | - bright color |
1291 +---------------+---------------+--------------------+
1292 | Oranges | $2.10 | - cures scurvy |
1293 | | | - tasty |
1294 +---------------+---------------+--------------------+
1296The row of `=`s separates the header from the table body, and can be
1297omitted for a headerless table. The cells of grid tables may contain
1298arbitrary block elements (multiple paragraphs, code blocks, lists,
1299etc.). Alignments are not supported, nor are cells that span multiple
1300columns or rows. Grid tables can be created easily using [Emacs table mode].
1302 [Emacs table mode]: http://table.sourceforge.net/
1305Title block
1306-----------
1308*Pandoc extension*.
1310If the file begins with a title block
1312 % title
1313 % author(s) (separated by semicolons)
1314 % date
1316it will be parsed as bibliographic information, not regular text. (It
1317will be used, for example, in the title of standalone LaTeX or HTML
1318output.) The block may contain just a title, a title and an author,
1319or all three elements. If you want to include an author but no
1320title, or a title and a date but no author, you need a blank line:
1323 % Author
1325 % My title
1327 % June 15, 2006
1329The title may occupy multiple lines, but continuation lines must
1330begin with leading space, thus:
1332 % My title
1333 on multiple lines
1335If a document has multiple authors, the authors may be put on
1336separate lines with leading space, or separated by semicolons, or
1337both. So, all of the following are equivalent:
1339 % Author One
1340 Author Two
1342 % Author One; Author Two
1344 % Author One;
1345 Author Two
1347The date must fit on one line.
1349All three metadata fields may contain standard inline formatting
1350(italics, links, footnotes, etc.).
1352Title blocks will always be parsed, but they will affect the output only
1353when the `--standalone` (`-s`) option is chosen. In HTML output, titles
1354will appear twice: once in the document head -- this is the title that
1355will appear at the top of the window in a browser -- and once at the
1356beginning of the document body. The title in the document head can have
1357an optional prefix attached (`--title-prefix` or `-T` option). The title
1358in the body appears as an H1 element with class "title", so it can be
1359suppressed or reformatted with CSS. If a title prefix is specified with
1360`-T` and no title block appears in the document, the title prefix will
1361be used by itself as the HTML title.
1363The man page writer extracts a title, man page section number, and
1364other header and footer information from the title line. The title
1365is assumed to be the first word on the title line, which may optionally
1366end with a (single-digit) section number in parentheses. (There should
1367be no space between the title and the parentheses.) Anything after
1368this is assumed to be additional footer and header text. A single pipe
1369character (`|`) should be used to separate the footer text from the header
1370text. Thus,
1372 % PANDOC(1)
1374will yield a man page with the title `PANDOC` and section 1.
1376 % PANDOC(1) Pandoc User Manuals
1378will also have "Pandoc User Manuals" in the footer.
1380 % PANDOC(1) Pandoc User Manuals | Version 4.0
1382will also have "Version 4.0" in the header.
1385Backslash escapes
1386-----------------
1388Except inside a code block or inline code, any punctuation or space
1389character preceded by a backslash will be treated literally, even if it
1390would normally indicate formatting. Thus, for example, if one writes
1392 *\*hello\**
1394one will get
1396 <em>*hello*</em>
1398instead of
1400 <strong>hello</strong>
1402This rule is easier to remember than standard markdown's rule,
1403which allows only the following characters to be backslash-escaped:
1405 \`*_{}[]()>#+-.!
1407(However, if the `--strict` option is supplied, the standard
1408markdown rule will be used.)
1410A backslash-escaped space is parsed as a nonbreaking space. It will
1411appear in TeX output as `~` and in HTML and XML as `\&#160;` or
1412`\&nbsp;`.
1414A backslash-escaped newline (i.e. a backslash occurring at the end of
1415a line) is parsed as a hard line break. It will appear in TeX output as
1416`\\` and in HTML as `<br />`. This is a nice alternative to
1417markdown's "invisible" way of indicating hard line breaks using
1418two trailing spaces on a line.
1420Backslash escapes do not work in verbatim contexts.
1422Smart punctuation
1423-----------------
1425If the `--smart` option is specified, pandoc will produce typographically
1426correct output, converting straight quotes to curly quotes, `---` and `--`
1427to Em-dashes, and `...` to ellipses. Nonbreaking spaces are inserted after
1428certain abbreviations, such as "Mr."
1430Note: if your LaTeX template uses the `csquotes` package, pandoc will
1431detect automatically this and use `\enquote{...}` for quoted text.
1433Inline formatting
1434-----------------
1436### Emphasis ###
1438To *emphasize* some text, surround it with `*`s or `_`, like this:
1440 This text is _emphasized with underscores_, and this
1441 is *emphasized with asterisks*.
1443Double `*` or `_` produces **strong emphasis**:
1445 This is **strong emphasis** and __with underscores__.
1447A `*` or `_` character surrounded by spaces, or backslash-escaped,
1448will not trigger emphasis:
1450 This is * not emphasized *, and \*neither is this\*.
1452Because `_` is sometimes used inside words and identifiers,
1453pandoc does not interpret a `_` surrounded by alphanumeric
1454characters as an emphasis marker. If you want to emphasize
1455just part of a word, use `*`:
1457 feas*ible*, not feas*able*.
1460### Strikeout ###
1462*Pandoc extension*.
1464To strikeout a section of text with a horizontal line, begin and end it
1465with `~~`. Thus, for example,
1467 This ~~is deleted text.~~
1470### Superscripts and subscripts ###
1472*Pandoc extension*.
1474Superscripts may be written by surrounding the superscripted text by `^`
1475characters; subscripts may be written by surrounding the subscripted
1476text by `~` characters. Thus, for example,
1478 H~2~O is a liquid. 2^10^ is 1024.
1480If the superscripted or subscripted text contains spaces, these spaces
1481must be escaped with backslashes. (This is to prevent accidental
1482superscripting and subscripting through the ordinary use of `~` and `^`.)
1483Thus, if you want the letter P with 'a cat' in subscripts, use
1484`P~a\ cat~`, not `P~a cat~`.
1487### Verbatim ###
1489To make a short span of text verbatim, put it inside backticks:
1491 What is the difference between `>>=` and `>>`?
1493If the verbatim text includes a backtick, use double backticks:
1495 Here is a literal backtick `` ` ``.
1497(The spaces after the opening backticks and before the closing
1498backticks will be ignored.)
1500The general rule is that a verbatim span starts with a string
1501of consecutive backticks (optionally followed by a space)
1502and ends with a string of the same number of backticks (optionally
1503preceded by a space).
1505Note that backslash-escapes (and other markdown constructs) do not
1506work in verbatim contexts:
1508 This is a backslash followed by an asterisk: `\*`.
1511Math
1512----
1514*Pandoc extension*.
1516Anything between two `$` characters will be treated as TeX math. The
1517opening `$` must have a character immediately to its right, while the
1518closing `$` must have a character immediately to its left. Thus,
1519`$20,000 and $30,000` won't parse as math. If for some reason
1520you need to enclose text in literal `$` characters, backslash-escape
1521them and they won't be treated as math delimiters.
1523TeX math will be printed in all output formats. How it is rendered
1524depends on the output format:
1526Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt
1527 ~ It will appear verbatim between `$` characters.
1529reStructuredText
1530 ~ It will be rendered using an interpreted text role `:math:`, as described
1531 [here](http://www.american.edu/econ/itex2mml/mathhack.rst).
1533AsciiDoc
1534 ~ It will be rendered as `latexmath:[...]`.
1536Texinfo
1537 ~ It will be rendered inside a `@math` command.
1539groff man
1540 ~ It will be rendered verbatim without `$`'s.
1542MediaWiki
1543 ~ It will be rendered inside `<math>` tags.
1545Textile
1546 ~ It will be rendered inside `<span class="math">` tags.
1548RTF, DocBook, OpenDocument, ODT
1549 ~ It will be rendered, if possible, using unicode characters,
1550 and will otherwise appear verbatim.
1552HTML, Slidy, DZSlides, S5, EPUB
1553 ~ The way math is rendered in HTML will depend on the
1554 command-line options selected:
1556 1. The default is to render TeX math as far as possible using unicode
1557 characters, as with RTF, DocBook, and OpenDocument output. Formulas
1558 are put inside a `span` with `class="math"`, so that they may be
1559 styled differently from the surrounding text if needed.
1561 2. If the `--latexmathml` option is used, TeX math will be displayed
1562 between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
1563 The [LaTeXMathML] script will be used to render it as formulas.
1564 (This trick does not work in all browsers, but it works in Firefox.
1565 In browsers that do not support LaTeXMathML, TeX math will appear
1566 verbatim between $ characters.)
1568 3. If the `--jsmath` option is used, TeX math will be put inside
1569 `<span>` tags (for inline math) or `<div>` tags (for display math)
1570 with class `math`. The [jsMath] script will be used to render
1571 it.
1573 4. If the `--mimetex` option is used, the [mimeTeX] CGI script will
1574 be called to generate images for each TeX formula. This should
1575 work in all browsers. The `--mimetex` option takes an optional URL
1576 as argument. If no URL is specified, it will be assumed that the
1577 mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
1579 5. If the `--gladtex` option is used, TeX formulas will be enclosed
1580 in `<eq>` tags in the HTML output. The resulting `htex` file may then
1581 be processed by [gladTeX], which will produce image files for each
1582 formula and an `html` file with links to these images. So, the
1583 procedure is:
1585 pandoc -s --gladtex myfile.txt -o myfile.htex
1586 gladtex -d myfile-images myfile.htex
1587 # produces myfile.html and images in myfile-images
1589 6. If the `--webtex` option is used, TeX formulas will be converted
1590 to `<img>` tags that link to an external script that converts
1591 formulas to images. The formula will be URL-encoded and concatenated
1592 with the URL provided. If no URL is specified, the Google Chart
1593 API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).
1596Raw HTML
1597--------
1599Markdown allows you to insert raw HTML (or DocBook) anywhere in a document
1600(except verbatim contexts, where `<`, `>`, and `&` are interpreted
1601literally).
1603The raw HTML is passed through unchanged in HTML, S5, Slidy, DZSlides, EPUB,
1604Markdown, and Textile output, and suppressed in other formats.
1606*Pandoc extension*.
1608Standard markdown allows you to include HTML "blocks": blocks
1609of HTML between balanced tags that are separated from the surrounding text
1610with blank lines, and start and end at the left margin. Within
1611these blocks, everything is interpreted as HTML, not markdown;
1612so (for example), `*` does not signify emphasis.
1614Pandoc behaves this way when `--strict` is specified; but by default,
1615pandoc interprets material between HTML block tags as markdown.
1616Thus, for example, Pandoc will turn
1618 <table>
1619 <tr>
1620 <td>*one*</td>
1621 <td>[a link](http://google.com)</td>
1622 </tr>
1623 </table>
1625into
1627 <table>
1628 <tr>
1629 <td><em>one</em></td>
1630 <td><a href="http://google.com">a link</a></td>
1631 </tr>
1632 </table>
1634whereas `Markdown.pl` will preserve it as is.
1636There is one exception to this rule: text between `<script>` and
1637`<style>` tags is not interpreted as markdown.
1639This departure from standard markdown should make it easier to mix
1640markdown with HTML block elements. For example, one can surround
1641a block of markdown text with `<div>` tags without preventing it
1642from being interpreted as markdown.
1644Raw TeX
1645-------
1647*Pandoc extension*.
1649In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be
1650included in a document. Inline TeX commands will be preserved and passed
1651unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use
1652LaTeX to include BibTeX citations:
1654 This result was proved in \cite{jones.1967}.
1656Note that in LaTeX environments, like
1658 \begin{tabular}{|l|l|}\hline
1659 Age & Frequency \\ \hline
1660 18--25 & 15 \\
1661 26--35 & 33 \\
1662 36--45 & 22 \\ \hline
1663 \end{tabular}
1665the material between the begin and end tags will be interpreted as raw
1666LaTeX, not as markdown.
1668Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
1669and ConTeXt.
1671### Macros ###
1673For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and
1674`\renewcommand` definitions and apply the resulting macros to all LaTeX
1675math. So, for example, the following will work in all output formats,
1676not just LaTeX:
1678 \newcommand{\tuple}[1]{\langle #1 \rangle}
1680 $\tuple{a, b, c}$
1682In LaTeX output, the `\newcommand` definition will simply be passed
1683unchanged to the output.
1686Links
1687-----
1689Markdown allows links to be specified in several ways.
1691### Automatic links ###
1693If you enclose a URL or email address in pointy brackets, it
1694will become a link:
1696 <http://google.com>
1697 <sam@green.eggs.ham>
1700### Inline links ###
1702An inline link consists of the link text in square brackets,
1703followed by the URL in parentheses. (Optionally, the URL can
1704be followed by a link title, in quotes.)
1706 This is an [inline link](/url), and here's [one with
1707 a title](http://fsf.org "click here for a good time!").
1709There can be no space between the bracketed part and the parenthesized part.
1710The link text can contain formatting (such as emphasis), but the title cannot.
1713### Reference links ###
1715An *explicit* reference link has two parts, the link itself and the link
1716definition, which may occur elsewhere in the document (either
1717before or after the link).
1719The link consists of link text in square brackets, followed by a label in
1720square brackets. (There can be space between the two.) The link definition
1721must begin at the left margin or indented no more than three spaces. It
1722consists of the bracketed label, followed by a colon and a space, followed by
1723the URL, and optionally (after a space) a link title either in quotes or in
1724parentheses.
1726Here are some examples:
1728 [my label 1]: /foo/bar.html "My title, optional"
1729 [my label 2]: /foo
1730 [my label 3]: http://fsf.org (The free software foundation)
1731 [my label 4]: /bar#special 'A title in single quotes'
1733The URL may optionally be surrounded by angle brackets:
1735 [my label 5]: <http://foo.bar.baz>
1737The title may go on the next line:
1739 [my label 3]: http://fsf.org
1740 "The free software foundation"
1742Note that link labels are not case sensitive. So, this will work:
1744 Here is [my link][FOO]
1746 [Foo]: /bar/baz
1748In an *implicit* reference link, the second pair of brackets is
1749empty, or omitted entirely:
1751 See [my website][], or [my website].
1753 [my website]: http://foo.bar.baz
1756Images
1757------
1759A link immediately preceded by a `!` will be treated as an image.
1760The link text will be used as the image's alt text:
1762 ![la lune](lalune.jpg "Voyage to the moon")
1764 ![movie reel]
1766 [movie reel]: movie.gif
1768### Pictures with captions ###
1770*Pandoc extension*.
1772An image occurring by itself in a paragraph will be rendered as
1773a figure with a caption.[^5] (In LaTeX, a figure environment will be
1774used; in HTML, the image will be placed in a `div` with class
1775`figure`, together with a caption in a `p` with class `caption`.)
1776The image's alt text will be used as the caption.
1778 ![This is the caption](/url/of/image.png)
1780[^5]: This feature is not yet implemented for RTF, OpenDocument, or
1781 ODT. In those formats, you'll just get an image in a paragraph by
1782 itself, with no caption.
1784If you just want a regular inline image, just make sure it is not
1785the only thing in the paragraph. One way to do this is to insert a
1786nonbreaking space after the image:
1788 ![This image won't be a figure](/url/of/image.png)\
1791Footnotes
1792---------
1794*Pandoc extension*.
1796Pandoc's markdown allows footnotes, using the following syntax:
1798 Here is a footnote reference,[^1] and another.[^longnote]
1800 [^1]: Here is the footnote.
1802 [^longnote]: Here's one with multiple blocks.
1804 Subsequent paragraphs are indented to show that they
1805 belong to the previous footnote.
1807 { some.code }
1809 The whole paragraph can be indented, or just the first
1810 line. In this way, multi-paragraph footnotes work like
1811 multi-paragraph list items.
1813 This paragraph won't be part of the note, because it
1814 isn't indented.
1816The identifiers in footnote references may not contain spaces, tabs,
1817or newlines. These identifiers are used only to correlate the
1818footnote reference with the note itself; in the output, footnotes
1819will be numbered sequentially.
1821The footnotes themselves need not be placed at the end of the
1822document. They may appear anywhere except inside other block elements
1823(lists, block quotes, tables, etc.).
1825Inline footnotes are also allowed (though, unlike regular notes,
1826they cannot contain multiple paragraphs). The syntax is as follows:
1828 Here is an inline note.^[Inlines notes are easier to write, since
1829 you don't have to pick an identifier and move down to type the
1830 note.]
1832Inline and regular footnotes may be mixed freely.
1835Citations
1836---------
1838*Pandoc extension*.
1840Pandoc can automatically generate citations and a bibliography in a number of
1841styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature,
1842you will need a bibliographic database in one of the following formats:
1844 Format File extension
1845 ------------ --------------
1846 MODS .mods
1847 BibTeX/BibLaTeX .bib
1848 RIS .ris
1849 EndNote .enl
1850 EndNote XML .xml
1851 ISI .wos
1852 MEDLINE .medline
1853 Copac .copac
1854 JSON citeproc .json
1856You will need to specify the bibliography file using the `--bibliography`
1857command-line option (which may be repeated if you have several
1858bibliographies).
1860By default, pandoc will use a Chicago author-date format for citations
1861and references. To use another style, you will need to use the
1862`--csl` option to specify a [CSL] 1.0 style file. A primer on
1863creating and modifying CSL styles can be found at
1864<http://citationstyles.org/downloads/primer.html>.
1865A repository of CSL styles can be found at
1866<https://github.com/citation-style-language/styles>.
1867See also <http://zotero.org/styles> for easy browsing.
1869Citations go inside square brackets and are separated by semicolons.
1870Each citation must have a key, composed of '@' + the citation
1871identifier from the database, and may optionally have a prefix,
1872a locator, and a suffix. Here are some examples:
1874 Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].
1876 Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].
1878 Blah blah [@smith04; @doe99].
1880A minus sign (`-`) before the `@` will suppress mention of
1881the author in the citation. This can be useful when the
1882author is already mentioned in the text:
1884 Smith says blah [-@smith04].
1886You can also write an in-text citation, as follows:
1888 @smith04 says blah.
1890 @smith04 [p. 33] says blah.
1892If the style calls for a list of works cited, it will be placed
1893at the end of the document. Normally, you will want to end your
1894document with an appropriate header:
1896 last paragraph...
1898 # References
1900The bibliography will be inserted after this header.
1903Producing HTML slide shows with Pandoc
1904======================================
1906You can use Pandoc to produce an HTML + javascript slide presentation
1907that can be viewed via a web browser. There are three ways to do this,
1908using [S5], [DZSlides], or [Slidy].
1910Here's the markdown source for a simple slide show, `eating.txt`:
1912 % Eating Habits
1913 % John Doe
1914 % March 22, 2005
1916 # In the morning
1918 - Eat eggs
1919 - Drink coffee
1921 # In the evening
1923 - Eat spaghetti
1924 - Drink wine
1926 --------------------------
1928 ![picture of spaghetti](images/spaghetti.jpg)
1930To produce the slide show, simply type
1932 pandoc -w s5 -s eating.txt > eating.html
1934for S5, or
1936 pandoc -w slidy -s eating.txt > eating.html
1938for Slidy, or
1940 pandoc -w dzslides -s eating.txt > eating.html
1942for DZSlides.
1944A title page is constructed automatically from the document's title
1945block. Each level-one header and horizontal rule begins a new slide.
1947For Slidy and S5, the file produced by pandoc with the `-s/--standalone`
1948option embeds a link to javascripts and CSS files, which are assumed to
1949be available at the relative path `s5/default` (for S5) or at the Slidy
1950website at `w3.org` (for Slidy). (These paths can be changed by setting
1951the `slidy-url` or `s5-url` variables; see `--variable`, above.) For DZSlides,
1952the (relatively short) javascript and css are included in the file by default.
1954You can change the style of the slides by putting customized CSS files
1955in `$DATADIR/s5/default` (for S5) or `$DATADIR/slidy` (for Slidy),
1956where `$DATADIR` is the user data directory (see `--data-dir`, above).
1957The originals may be found in pandoc's system data directory (generally
1958`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any
1959files it does not find in the user data directory.
1961The `--self-contained` option can be used to produce a single file that
1962contains all of the data necessary to display the slide show, including
1963linked scripts, stylesheets, images, and videos.
1965Incremental lists
1966-----------------
1968By default, these writers produces lists that display "all at once."
1969If you want your lists to display incrementally (one item at a time),
1970use the `-i` option. If you want a particular list to depart from the
1971default (that is, to display incrementally without the `-i` option and
1972all at once with the `-i` option), put it in a block quote:
1974 > - Eat spaghetti
1975 > - Drink wine
1977In this way incremental and nonincremental lists can be mixed in
1978a single document.
1980Literate Haskell support
1981========================
1983If you append `+lhs` to an appropriate input or output format (`markdown`,
1984`rst`, or `latex` for input or output; `html` for output only), pandoc
1985will treat the document as literate Haskell source. This means that
1987 - In markdown input, "bird track" sections will be parsed as Haskell
1988 code rather than block quotations. Text between `\begin{code}`
1989 and `\end{code}` will also be treated as Haskell code.
1991 - In markdown output, code blocks with class `haskell` will be
1992 rendered using bird tracks, and block quotations will be
1993 indented one space, so they will not be treated as Haskell code.
1994 In addition, headers will be rendered setext-style (with underlines)
1995 rather than atx-style (with '#' characters). (This is because ghc
1996 treats '#' characters in column 1 as introducing line numbers.)
1998 - In restructured text input, "bird track" sections will be parsed
1999 as Haskell code.
2001 - In restructured text output, code blocks with class `haskell` will
2002 be rendered using bird tracks.
2004 - In LaTeX input, text in `code` environments will be parsed as
2005 Haskell code.
2007 - In LaTeX output, code blocks with class `haskell` will be rendered
2008 inside `code` environments.
2010 - In HTML output, code blocks with class `haskell` will be rendered
2011 with class `literatehaskell` and bird tracks.
2013Examples:
2015 pandoc -f markdown+lhs -t html
2017reads literate Haskell source formatted with markdown conventions and writes
2018ordinary HTML (without bird tracks).
2020 pandoc -f markdown+lhs -t html+lhs
2022writes HTML with the Haskell code in bird tracks, so it can be copied
2023and pasted as literate Haskell source.
2025Authors
2026=======
2028© 2006-2011 John MacFarlane (jgm at berkeley dot edu). Released under the
2029[GPL], version 2 or greater. This software carries no warranty of
2030any kind. (See COPYRIGHT for full copyright and warranty notices.)
2031Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,
2032Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,
2033Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton,
2034Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner, qerub,
2035Christopher Sawicki, Kelsey Hightower.
2037[markdown]: http://daringfireball.net/projects/markdown/
2038[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
2039[S5]: http://meyerweb.com/eric/tools/s5/
2040[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
2041[HTML]: http://www.w3.org/TR/html40/
2042[LaTeX]: http://www.latex-project.org/
2043[ConTeXt]: http://www.pragma-ade.nl/
2044[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
2045[DocBook XML]: http://www.docbook.org/
2046[OpenDocument XML]: http://opendocument.xml.org/
2047[ODT]: http://en.wikipedia.org/wiki/OpenDocument
2048[Textile]: http://redcloth.org/textile
2049[MediaWiki markup]: http://www.mediawiki.org/wiki/Help:Formatting
2050[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html
2051[Haskell]: http://www.haskell.org/
2052[GNU Texinfo]: http://www.gnu.org/software/texinfo/
2053[Emacs Org-Mode]: http://orgmode.org
2054[AsciiDoc]: http://www.methods.co.nz/asciidoc/
2055[EPUB]: http://www.idpf.org/
2056[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
2057[DZSlides]: http://paulrouget.com/dzslides/