5Pandoc is a [Haskell] library for converting from one markup format to
6another, and a command-line tool that uses this library. It can read
7[markdown] and (subsets of) [reStructuredText], [HTML], and [LaTeX]; and
8it can write plain text, [markdown], [reStructuredText], [HTML], [LaTeX],
9[ConTeXt], [RTF], [DocBook XML], [OpenDocument XML], [ODT], [GNU Texinfo],
10[MediaWiki markup], [EPUB], [groff man] pages, and [Slidy] or [S5]
13Pandoc's enhanced version of markdown includes syntax for footnotes,
14tables, flexible ordered lists, definition lists, delimited code blocks,
15superscript, subscript, strikeout, title blocks, automatic tables of
16contents, embedded LaTeX math, and markdown inside HTML block elements.
17(These enhancements can be disabled if a drop-in replacement for
18`Markdown.pl` is desired.)
20In contrast to most existing tools for converting markdown to HTML, which
21use regex substitutions, Pandoc has a modular design: it consists of a
22set of readers, which parse text in a given format and produce a native
23representation of the document, and a set of writers, which convert
24this native representation into a target format. Thus, adding an input
25or output format requires only adding a reader or writer.
27© 2006-2010 John MacFarlane (jgm at berkeley dot edu). Released under the
28[GPL], version 2 or greater. This software carries no warranty of
29any kind. (See COPYRIGHT for full copyright and warranty notices.)
30Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,
31Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,
32rodja.trappe, Bradley Kuhn, thsutton, Justin Bogner.
37If you run `pandoc` without arguments, it will accept input from
38stdin. If you run it with file names as arguments, it will take input
39from those files. By default, `pandoc` writes its output to stdout.[^1]
40If you want to write to a file, use the `-o` option:
42 pandoc -o hello.html hello.txt
44[^1]: The exceptions are for `odt` and `epub`. Since these are
45 a binary output formats, an output file must be specified explicitly.
47Note that you can specify multiple input files on the command line.
48`pandoc` will concatenate them all (with blank lines between them)
51 pandoc -s ch1.txt ch2.txt refs.txt > book.html
53(The `-s` option here tells `pandoc` to produce a standalone HTML file,
54with a proper header, rather than a fragment. For more details on this
55and many other command-line options, see below.)
57Instead of a filename, you can specify an absolute URI. In this
58case pandoc will attempt to download the content via HTTP:
60 pandoc -f html -t markdown http://www.fsf.org
62The format of the input and output can be specified explicitly using
63command-line options. The input format can be specified using the
64`-r/--read` or `-f/--from` options, the output format using the
65`-w/--write` or `-t/--to` options. Thus, to convert `hello.txt` from
66markdown to LaTeX, you could type:
68 pandoc -f markdown -t latex hello.txt
70To convert `hello.html` from html to markdown:
72 pandoc -f html -t markdown hello.html
74Supported output formats include `markdown`, `latex`, `context`
75(ConTeXt), `html`, `rtf` (rich text format), `rst`
76(reStructuredText), `docbook` (DocBook XML), `opendocument`
77(OpenDocument XML), `odt` (OpenOffice text document), `texinfo`, (GNU
78Texinfo), `mediawiki` (MediaWiki markup), `epub` (EPUB ebook),
79`man` (groff man), `slidy` (slidy HTML and javascript slide show), or
80`s5` (S5 HTML and javascript slide show).
82Supported input formats include `markdown`, `html`, `latex`, and `rst`.
83Note that the `rst` reader only parses a subset of reStructuredText
84syntax. For example, it doesn't handle tables, option lists, or
85footnotes. But for simple documents it should be adequate. The `latex`
86and `html` readers are also limited in what they can do.
88If you don't specify a reader or writer explicitly, `pandoc` will
89try to determine the input and output format from the extensions of
90the input and output filenames. Thus, for example,
92 pandoc -o hello.tex hello.txt
94will convert `hello.txt` from markdown to LaTeX. If no output file
95is specified (so that output goes to stdout), or if the output file's
96extension is unknown, the output format will default to HTML.
97If no input file is specified (so that input comes from stdin), or
98if the input files' extensions are unknown, the input format will
99be assumed to be markdown unless explicitly specified.
104All input is assumed to be in the UTF-8 encoding, and all output
105is in UTF-8. If your local character encoding is not UTF-8 and you use
106accented or foreign characters, you should pipe the input and output
107through [`iconv`]. For example,
109 iconv -t utf-8 source.txt | pandoc | iconv -f utf-8 > output.html
111will convert `source.txt` from the local encoding to UTF-8, then
112convert it to HTML, then convert back to the local encoding,
113putting the output in `output.html`.
121The standard Pandoc installation includes `markdown2pdf`, a wrapper
122around `pandoc` and `pdflatex` that produces PDFs directly from markdown
123sources. The default behavior of `markdown2pdf` is to create a file with
124the same base name as the first argument and the extension `pdf`; thus,
127 markdown2pdf sample.txt endnotes.txt
129will produce `sample.pdf`. (If `sample.pdf` exists already,
130it will be backed up before being overwritten.) An output file
131name can be specified explicitly using the `-o` option:
133 markdown2pdf -o book.pdf chap1 chap2
135If no input file is specified, input will be taken from stdin.
136All of `pandoc`'s options will work with `markdown2pdf` as well.
138`markdown2pdf` assumes that `pdflatex` is in the path. It also
139assumes that the following LaTeX packages are available:
140`unicode`, `fancyhdr` (if you have verbatim text in footnotes),
141`graphicx` (if you use images), `array` (if you use tables),
142and `ulem` (if you use strikeout text). If they are not already
143included in your LaTeX distribution, you can get them from
144[CTAN]. A full [TeX Live] or [MacTeX] distribution will have all of
150A user who wants a drop-in replacement for `Markdown.pl` may create
151a symbolic link to the `pandoc` executable called `hsmarkdown`. When
152invoked under the name `hsmarkdown`, `pandoc` will behave as if the
153`--strict` flag had been selected, and no command-line options will be
154recognized. However, this approach does not work under Cygwin, due to
155problems with its simulation of symbolic links.
157[Cygwin]: http://www.cygwin.com/
158[`iconv`]: http://www.gnu.org/software/libiconv/
159[CTAN]: http://www.ctan.org "Comprehensive TeX Archive Network"
160[TeX Live]: http://www.tug.org/texlive/
161[MacTeX]: http://www.tug.org/mactex/
166Various command-line options can be used to customize the output.
167For further documentation, see the `pandoc(1)` man page.
169`-f`, `--from`, `-r`, or `--read` *format*
170: specifies the input format (the format Pandoc will be converting
171 *from*). *format* can be `native`, `markdown`, `rst`, `html`, or
172 `latex`. (`+lhs` can be appended to indicate that the input should
173 be treated as literate Haskell source. See
174 [Literate Haskell support](#literate-haskell-support), below.)
176`-t`, `--to`, `-w`, or `--write` *format*
177: specifies the output format -- the format Pandoc will
178 be converting *to*. *format* can be `native`, `html`, `slidy`, `s5`,
179 `docbook`, `opendocument`, `latex`, `context`, `markdown`, `man`,
180 `plain`, `rst`, and `rtf`. (`+lhs` can be appended to indicate that
181 the output should be treated as literate Haskell source. See
182 [Literate Haskell support](#literate-haskell-support), below.)
184`-s` or `--standalone`
185: indicates that a standalone document is to be produced (with
186 appropriate headers and footers), rather than a fragment.
188`-o` or `--output` *filename*
189: sends output to *filename*. If this option is not specified,
190 or if its argument is `-`, output will be sent to stdout.
191 (Exception: if the output format is `odt` or `epub`, output to
194`-p` or `--preserve-tabs`
195: causes tabs in the source text to be preserved, rather than converted
196 to spaces (the default).
198`--tab-stop` *tabstop*
199: sets the number of spaces per tab to *tabstop* (defaults to 4).
202: specifies that strict markdown syntax is to be used, without
203 pandoc's usual extensions and variants (described below). When the
204 input format is HTML, this means that constructs that have no
205 equivalents in standard markdown (e.g. definition lists or strikeout
206 text) will be parsed as raw HTML.
209: causes reference-style links to be used in markdown
210 and reStructuredText output. By default inline links are used.
213: causes the HTML and LaTeX readers to parse HTML codes and LaTeX
214 environments that it can't translate as raw HTML or LaTeX. Raw HTML can
215 be printed in markdown, reStructuredText, HTML, Slidy, and S5
216 output; raw LaTeX can be printed in markdown, reStructuredText,
217 LaTeX, and ConTeXt output. The default is for the readers to omit
218 untranslatable HTML codes and LaTeX environments. (The LaTeX reader
219 does pass through untranslatable LaTeX *commands*, even if `-R` is
222`-C` or `--custom-header` *filename*
223: can be used to specify a custom document header. Implies `--standalone`.
224 *Note: this option is deprecated. Use of `--template` is preferred.*
226`--toc` or `--table-of-contents`
227: includes an automatically generated table of contents (or, in the
228 case of `latex`, `context`, and `rst`, an instruction to create
229 one) in the output document. This option has no effect with `man`,
230 `docbook`, `slidy`, or `s5` output formats.
232`--base-header-level` *level*
233: specifies the base level for headers (defaults to 1).
236: uses *file* as a custom template for the generated document. Implies
237 `-s`. See [Templates](#templates) below for a description
238 of template syntax. If this option is not used, a default
239 template appropriate for the output format will be used. See also
240 `-D/--print-default-template`.
242`-V` *key=val*, `--variable=`*key:val*
243: sets the template variable *key* to the value *val* when rendering the
244 document in standalone mode. This is only useful when the
245 `--template` option is used to specify a custom template, since
246 pandoc automatically sets the variables used in the default
249`-c` or `--css` *filename*
250: allows the user to specify a custom stylesheet that will be linked to
251 in HTML, Slidy, and S5 output. This option can be used repeatedly
252 to include multiple stylesheets. They will be included in the order
253 specified. Implies `--standalone`.
255`-H` or `--include-in-header` *filename*
256: includes the contents of *filename* (verbatim) at the end of the
257 document header. This can be used, for example, to include special
258 CSS or javascript in HTML documents. This option can be used
259 repeatedly to include multiple files in the header. They will be
260 included in the order specified. Implies `--standalone`.
262`-B` or `--include-before-body` *filename*
263: includes the contents of *filename* (verbatim) at the beginning of
264 the document body (e.g. after the `<body>` tag in HTML, or the
265 `\begin{document}` command in LaTeX). This can be used to include
266 navigation bars or banners in HTML documents. This option can be
267 used repeatedly to include multiple files. They will be included in
268 the order specified. Implies `--standalone`.
270`-A` or `--include-after-body` *filename*
271: includes the contents of *filename* (verbatim) at the end of
272 the document body (before the `</body>` tag in HTML, or the
273 `\end{document}` command in LaTeX). This option can be be used
274 repeatedly to include multiple files. They will be included in the
275 order specified. Implies `--standalone`.
277`--reference-odt` *filename*
278: uses the specified file as a style reference in producing an ODT.
279 For best results, the reference ODT should be a modified version
280 of an ODT produced using pandoc. The contents of the reference ODT
281 are ignored, but its stylesheets are used in the new ODT. If no
282 reference ODT is specified on the command line, pandoc will look
283 for a file `reference.odt` in the user data directory (see
284 `--data-dir`, below). If it is not found there, sensible defaults
287`--epub-stylesheet` *filename*
288: uses the specified CSS file to style the EPUB. If no stylesheet
289 is specified, pandoc will look for a file `epub.css` in the
290 user data directory (see `--data-dir`, below). If it is not
291 found there, sensible defaults will be used.
293`--epub-metadata` *filename*
294: looks in the specified XML file for metadata for the EPUB.
295 The file should contain a series of [Dublin Core elements],
298 <dc:rights>Creative Commons</dc:rights>
299 <dc:language>es-AR</dc:language>
301 By default, pandoc will include the following metadata elements:
302 `<dc:title>` (from the document title), `<dc:creator>` (from the
303 document authors), `<dc:language>` (from the locale), and
304 `<dc:identifier id="BookId">` (a randomly generated UUID). Any of
305 these may be overridden by elements in the metadata file.
307`-D` or `--print-default-template` *format*
308: prints the default template for an output *format*. (See `-t`
309 for a list of possible *format*s.)
311`-T` or `--title-prefix` *string*
312: includes *string* as a prefix at the beginning of the title that
313 appears in the HTML header (but not in the title as it appears at
314 the beginning of the HTML body). (See below on
315 [Title Blocks](#title-blocks).) Implies `--standalone`.
318: causes `pandoc` to produce typographically correct output, along the
319 lines of John Gruber's [Smartypants]. Straight quotes are converted
320 to curly quotes, `---` to dashes, and `...` to ellipses. Nonbreaking
321 spaces are inserted after certain abbreviations, such as "Mr."
322 (Note: This option is only significant when the input format is
323 `markdown`. It is selected automatically when the output format is
324 `latex` or `context`.)
326`-m`*[url]* or `--latexmathml`*[=url]*
327: causes `pandoc` to use the [LaTeXMathML] script to display
328 TeX math in HTML, Slidy, or S5. If a local copy of `LaTeXMathML.js`
329 is available on the webserver where the page will be viewed, provide
330 a *url* and a link will be inserted in the generated HTML. If
331 no *url* is provided, the contents of the script will be inserted
332 directly; this provides portability at the price of efficiency. If
333 you plan to use math on several pages, it is much better to link to
334 a copy of `LaTeXMathML.js`, which can be cached.
337: causes `pandoc` to convert all TeX math to MathML.
338 In standalone mode, a small javascript will be inserted that allows
339 the MathML to be viewed on some browsers.
342: causes `pandoc` to use the [jsMath] script to display
343 TeX math in HTML, Slidy, or S5. The *url* should point to the jsMath
344 load script (e.g. `jsMath/easy/load.js`). If it is provided, a link
345 to it will be included in the header of standalone HTML documents.
348: causes `pandoc` to use [MathJax] to display embedded TeX math in HTML
349 output. The *URL* should point to the `MathJax.js` load script.
350 Pandoc will use MathML with MathJax, so your `config/MathJax.js`
351 file should contain the following settings:
353 extensions: ["mml2jax.js"],
354 jax: ["input/MathML", "output/HTML-CSS"],
357: causes TeX formulas to be enclosed in `<eq>` tags in HTML, Slidy, or
358 S5 output. This output can then be processed by [gladTeX] to produce
359 links to images with the typeset formulas.
362: causes TeX formulas to be replaced by `<img>` tags linking to the
363 [mimeTeX] CGI script, which will produce images with the typeset
367: causes TeX formulas to be replaced by `<img>` tags linking to an
368 external service that converts TeX formulas to images. The formula
369 will be concatenated with the URL provided. If no URL
370 is specified, the Google Chart API is used.
372`-i` or `--incremental`
373: causes all lists in Slidy or S5 output to be displayed incrementally by
374 default (one item at a time). The normal default is for lists to be
375 displayed all at once.
378: causes all the CSS and javascript needed for a Slidy or S5 slide show
379 to be included in the output, so that the slide show will work even
380 when no internet connection is available.
383: creates LaTeX outut suitable for processing by XeTeX.
385`-N` or `--number-sections`
386: causes sections to be numbered in LaTeX, ConTeXt, or HTML output.
387 By default, sections are not numbered.
390: causes sections to be wrapped in `<div>` tags. In this case,
391 [section identifiers](#header-identifiers-in-html)
392 are attached to the enclosing `<div>` rather than the header itself.
395: disables text-wrapping in output. By default, text is wrapped
396 appropriately for the output format.
399: sanitizes HTML (in markdown or HTML input) using a whitelist.
400 Unsafe tags are replaced by HTML comments; unsafe attributes
401 are omitted. URIs in links and images are also checked against a
402 whitelist of URI schemes.
404`--email-obfuscation`*=none|javascript|references*
405: specifies a method for obfuscating `mailto:` links in HTML documents.
406 *none* leaves `mailto:` links as they are. *javascript* obfuscates
407 them using javascript. *references* obfuscates them by printing their
408 letters as decimal or hexadecimal character references. If `--strict`
409 is specified, *references* is used regardless of the presence
412`--id-prefix`*=string*
413: specifies a prefix to be added to all automatically generated identifiers
414 in HTML output. This is useful for preventing duplicate identifiers
415 when generating fragments to be included in other pages.
417`--indented-code-classes`*=classes*
418: specifies classes to use for indented code blocks--for example,
419 `perl,numberLines` or `haskell`. Multiple classes may be separated
422`--data-dir`*=directory*
423: specifies the user data directory to search for pandoc data files.
424 If this option is not specified, the default user data directory
431 C:\Documents And Settings\USERNAME\Application Data\pandoc
433 in Windows. A `reference.odt`, `epub.css`, `templates` directory,
434 or `s5` directory placed in this directory will override pandoc's
438: is intended to make it easier to create wrapper scripts that use
439 Pandoc. It causes Pandoc to dump information about the arguments
440 with which it was called to stdout, then exit. The first line
441 printed is the name of the output file specified using the `-o`
442 or `--output` option, or `-` if output would go to stdout. The
443 remaining lines, if any, list command-line arguments. These will
444 include the names of input files and any special options passed
445 after ` -- ` on the command line. So, for example,
447 pandoc --dump-args -o foo.html -s foo.txt \
448 appendix.txt -- -e latin1
450 will cause the following to be printed to stdout:
452 foo.html foo.txt appendix.txt -e latin1
455: causes Pandoc to ignore all command-line arguments.
456 Regular Pandoc options are not ignored. Thus, for example,
458 pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
462 pandoc -o foo.html -s
465: prints the version number to STDERR.
468: prints a usage message to STDERR.
470[Smartypants]: http://daringfireball.net/projects/smartypants/
471[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/
472[jsMath]: http://www.math.union.edu/~dpvc/jsmath/
473[MathJax]: http://www.mathjax.org/
474[gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html
475[mimeTeX]: http://www.forkosh.com/mimetex.html
476[Dublin Core elements]: http://dublincore.org/documents/dces/
481When the `-s/--standalone` option is used, pandoc uses a template to
482add header and footer material that is needed for a self-standing
483document. To see the default template that is used, just type
487where `FORMAT` is the name of the output format. A custom template
488can be specified using the `--template` option. You can also override
489the system default templates for a given output format `FORMAT`
490by putting a file `templates/FORMAT.template` in the user data
491directory (see `--data-dir`, above).
493Templates may contain *variables*. Variable names are sequences of
494alphanumerics, `-`, and `_`, starting with a letter. A variable name
495surrounded by `$` signs will be replaced by its value. For example,
496the string `$title$` in
498 <title>$title$</title>
500will be replaced by the document title.
502To write a literal `$` in a template, use `$$`.
504Some variables are set automatically by pandoc. These vary somewhat
505depending on the output format, but include:
508: contents specified by `-C/--custom-header`
510: contents specified by `-H/--include-in-header` (may have multiple
513: non-null value if `--toc/--table-of-contents` was specified
515: contents specified by `-B/--include-before-body` (may have
518: contents specified by `-A/--include-after-body` (may have
523: title of document, as specified in title block
525: author of document, as specified in title block (may have
528: date of document, as specified in title block
530Variables may be set at the command line using the `-V/--variable`
531option. This allows users to include custom variables in their
534Templates may contain conditionals. The syntax is as follows:
542This will include `X` in the template if `variable` has a non-null
543value; otherwise it will include `Y`. `X` and `Y` are placeholders for
544any valid template text, and may include interpolated variables or other
545conditionals. The `$else$` section may be omitted.
547When variables can have multiple values (for example, `author` in
548a multi-author document), you can use the `$for$` keyword:
551 <meta name="author" content="$author$" />
554You can optionally specify a separator to be used between
557 $for(author)$$author$$sep$, $endfor$
559Pandoc's markdown vs. standard markdown
560=======================================
562In parsing markdown, Pandoc departs from and extends [standard markdown]
563in a few respects. Except where noted, these differences can
564be suppressed by specifying the `--strict` command-line option.
566[standard markdown]: http://daringfireball.net/projects/markdown/syntax
567 "Markdown syntax description"
572Except inside a code block or inline code, any punctuation or space
573character preceded by a backslash will be treated literally, even if it
574would normally indicate formatting. Thus, for example, if one writes
584 <strong>hello</strong>
586This rule is easier to remember than standard markdown's rule,
587which allows only the following characters to be backslash-escaped:
591A backslash-escaped space is parsed as a nonbreaking space. It will
592appear in TeX output as `~` and in HTML and XML as `\ ` or
595A backslash-escaped newline (i.e. a backslash occurring at the end of
596a line) is parsed as a hard line break. It will appear in TeX output as
597`\\` and in HTML as `<br />`. This is a nice alternative to
598markdown's "invisible" way of indicating hard line breaks using
599two trailing spaces on a line.
601Subscripts and superscripts
602---------------------------
604Superscripts may be written by surrounding the superscripted text by `^`
605characters; subscripts may be written by surrounding the subscripted
606text by `~` characters. Thus, for example,
608 H~2~O is a liquid. 2^10^ is 1024.
610If the superscripted or subscripted text contains spaces, these spaces
611must be escaped with backslashes. (This is to prevent accidental
612superscripting and subscripting through the ordinary use of `~` and `^`.)
613Thus, if you want the letter P with 'a cat' in subscripts, use
614`P~a\ cat~`, not `P~a cat~`.
619To strikeout a section of text with a horizontal line, begin and end it
620with `~~`. Thus, for example,
622 This ~~is deleted text.~~
627Pandoc behaves differently from standard markdown on some "edge
628cases" involving lists. Consider this source:
638Pandoc transforms this into a "compact list" (with no `<p>` tags around
639"First", "Second", or "Third"), while markdown puts `<p>` tags around
640"Second" and "Third" (but not "First"), because of the blank space
641around "Third". Pandoc follows a simple rule: if the text is followed by
642a blank line, it is treated as a paragraph. Since "Second" is followed
643by a list, and not a blank line, it isn't treated as a paragraph. The
644fact that the list is followed by a blank line is irrelevant. (Note:
645Pandoc works this way even when the `--strict` option is specified. This
646behavior is consistent with the official markdown syntax description,
647even though it is different from that of `Markdown.pl`.)
652Unlike standard markdown, Pandoc allows ordered list items to be marked
653with uppercase and lowercase letters and roman numerals, in addition to
654arabic numerals. (This behavior can be turned off using the `--strict`
655option.) List markers may be enclosed in parentheses or followed by a
656single right-parentheses or period. They must be separated from the
657text that follows by at least one space, and, if the list marker is a
658capital letter with a period, by at least two spaces.[^2]
660[^2]: The point of this rule is to ensure that normal paragraphs
661 starting with people's initials, like
663 B. Russell was an English philosopher.
665 do not get treated as list items.
667 This rule will not prevent
671 from being interpreted as a list item. In this case, a backslash
676Pandoc also pays attention to the type of list marker used, and to the
677starting number, and both of these are preserved where possible in the
678output format. Thus, the following yields a list with numbers followed
679by a single parenthesis, starting with 9, and a sublist with lowercase
689Note that Pandoc pays attention only to the *starting* marker in a list.
690So, the following yields a list numbered sequentially starting from 2:
697If default list markers are desired, use `#.`:
706The special list marker `@` can be used for sequentially numbered
707examples. The first list item with a `@` marker will be numbered '1',
708the next '2', and so on, throughout the document. The numbered examples
709need not occur in a single list; each new list using `@` will take up
710where the last stopped. So, for example:
712 (@) My first example will be numbered (1).
713 (@) My second example will be numbered (2).
715 Explanation of examples.
717 (@) My third example will be numbered (3).
719Numbered examples can be labeled and referred to elsewhere in the
722 (@good) This is a good example.
724 As (@good) illustrates, ...
726The label can be any string of alphanumeric characters, underscores,
732Pandoc supports definition lists, using a syntax inspired by
733[PHP Markdown Extra] and [reStructuredText]:[^3]
739 Term 2 with *inline markup*
743 { some code, part of Definition 2 }
745 Third paragraph of definition 2.
747Each term must fit on one line, which may optionally be followed by
748a blank line, and must be followed by one or more definitions.
749A definition begins with a colon or tilde, which may be indented one
750or two spaces. A term may have multiple definitions, and each definition
751may consist of one or more block elements (paragraph, code block, list,
752etc.), each indented four spaces or one tab stop.
754If you leave space after the definition (as in the example above),
755the blocks of the definitions will be considered paragraphs. In some
756output formats, this will mean greater spacing between term/definition
757pairs. For a compact definition list, do not leave space between the
758definition and the next term:
766[^3]: I have also been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).
768[PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
773Pandoc allows implicit reference links with just a single set of
774brackets. So, the following links are equivalent:
777 2. Here's my [link][]
781(Note: Pandoc works this way even if `--strict` is specified, because
782`Markdown.pl` 1.0.2b7 allows single-bracket links.)
787Pandoc's markdown allows footnotes, using the following syntax:
789 Here is a footnote reference,[^1] and another.[^longnote]
791 [^1]: Here is the footnote.
793 [^longnote]: Here's one with multiple blocks.
795 Subsequent paragraphs are indented to show that they
796 belong to the previous footnote.
800 The whole paragraph can be indented, or just the first
801 line. In this way, multi-paragraph footnotes work like
802 multi-paragraph list items.
804 This paragraph won't be part of the note, because it isn't indented.
806The identifiers in footnote references may not contain spaces, tabs,
807or newlines. These identifiers are used only to correlate the
808footnote reference with the note itself; in the output, footnotes
809will be numbered sequentially.
811The footnotes themselves need not be placed at the end of the
812document. They may appear anywhere except inside other block elements
813(lists, block quotes, tables, etc.).
815Inline footnotes are also allowed (though, unlike regular notes,
816they cannot contain multiple paragraphs). The syntax is as follows:
818 Here is an inline note.^[Inlines notes are easier to write, since
819 you don't have to pick an identifier and move down to type the
822Inline and regular footnotes may be mixed freely.
827Three kinds of tables may be used. All three kinds presuppose the use of
828a fixed-width font, such as Courier.
830**Simple tables** look like this:
832 Right Left Center Default
833 ------- ------ ---------- -------
838 Table: Demonstration of simple table syntax.
840The headers and table rows must each fit on one line. Column
841alignments are determined by the position of the header text relative
842to the dashed line below it:[^4]
844 - If the dashed line is flush with the header text on the right side
845 but extends beyond it on the left, the column is right-aligned.
846 - If the dashed line is flush with the header text on the left side
847 but extends beyond it on the right, the column is left-aligned.
848 - If the dashed line extends beyond the header text on both sides,
849 the column is centered.
850 - If the dashed line is flush with the header text on both sides,
851 the default alignment is used (in most cases, this will be left).
853[^4]: This scheme is due to Michel Fortin, who proposed it on the
854 [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).
856The table must end with a blank line, or a line of dashes followed by
857a blank line. A caption may optionally be provided (as illustrated in
858the example above). A caption is a paragraph beginning with the string
859`Table:` (or just `:`), which will be stripped off. It may appear either
860before or after the table.
862The column headers may be omitted, provided a dashed line is used
863to end the table. For example:
865 ------- ------ ---------- -------
869 ------- ------ ---------- -------
871When headers are omitted, column alignments are determined on the basis
872of the first line of the table body. So, in the tables above, the columns
873would be right, left, center, and right aligned, respectively.
875**Multiline tables** allow headers and table rows to span multiple lines
876of text (but cells that span multiple columns or rows of the table are
877not supported). Here is an example:
879 -------------------------------------------------------------
880 Centered Default Right Left
881 Header Aligned Aligned Aligned
882 ----------- ------- --------------- -------------------------
883 First row 12.0 Example of a row that
884 spans multiple lines.
886 Second row 5.0 Here's another one. Note
887 the blank line between
889 -------------------------------------------------------------
891 Table: Here's the caption. It, too, may span
894These work like simple tables, but with the following differences:
896 - They must begin with a row of dashes, before the header text
897 (unless the headers are omitted).
898 - They must end with a row of dashes, then a blank line.
899 - The rows must be separated by blank lines.
901In multiline tables, the table parser pays attention to the widths of
902the columns, and the writers try to reproduce these relative widths in
903the output. So, if you find that one of the columns is too narrow in the
904output, try widening it in the markdown source.
906Headers may be omitted in multiline tables as well as simple tables:
908 ----------- ------- --------------- -------------------------
909 First row 12.0 Example of a row that
910 spans multiple lines.
912 Second row 5.0 Here's another one. Note
913 the blank line between
915 -------------------------------------------------------------
917 : Here's a multiline table without headers.
919It is possible for a multiline table to have just one row, but the row
920should be followed by a blank line (and then the row of dashes that ends
921the table), or the table may be interpreted as a simple table.
923**Grid tables** look like this:
927 +---------------+---------------+--------------------+
928 | Fruit | Price | Advantages |
929 +===============+===============+====================+
930 | Bananas | $1.34 | - built-in wrapper |
931 | | | - bright color |
932 +---------------+---------------+--------------------+
933 | Oranges | $2.10 | - cures scurvy |
935 +---------------+---------------+--------------------+
937The row of `=`s separates the header from the table body, and can be
938omitted for a headerless table. The cells of grid tables may contain
939arbitrary block elements (multiple paragraphs, code blocks, lists,
940etc.). Alignments are not supported, nor are cells that span multiple
941columns or rows. Grid tables can be created easily using [Emacs table mode].
943 [Emacs table mode]: http://table.sourceforge.net/
948In addition to standard indented code blocks, Pandoc supports
949*delimited* code blocks. These begin with a row of three or more
950tildes (`~`) and end with a row of tildes that must be at least
951as long as the starting row. Everything between the tilde-lines
952is treated as code. No indentation is necessary:
958Like regular code blocks, delimited code blocks must be separated
959from surrounding text by blank lines.
961If the code itself contains a row of tildes, just use a longer
962row of tildes at the start and end:
966 code including tildes
970Optionally, you may specify the language of the code block using
973 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines}
975 qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
976 qsort (filter (>= x) xs)
977 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
979Some output formats can use this information to do syntax highlighting.
980Currently, the only output format that uses this information is HTML.
982If pandoc has been compiled with syntax highlighting support, then the
983code block above will appear highlighted, with numbered lines. (To see
984which languages are supported, do `pandoc --version`.)
986If pandoc has not been compiled with syntax highlighting support, the
987code block above will appear as follows:
989 <pre class="haskell">
998An image occurring by itself in a paragraph will be rendered as
999a figure with a caption.[^5] (In LaTeX, a figure environment will be
1000used; in HTML, the image will be placed in a `div` with class
1001`figure`, together with a caption in a `p` with class `caption`.)
1002The image's alt text will be used as the caption.
1004 
1006[^5]: This feature is not yet implemented for RTF, OpenDocument, or
1007 ODT. In those formats, you'll just get an image in a paragraph by
1008 itself, with no caption.
1010If you just want a regular inline image, just make sure it is not
1011the only thing in the paragraph. One way to do this is to insert a
1012nonbreaking space after the image:
1014 \
1019If the file begins with a title block
1022 % author(s) (separated by semicolons)
1025it will be parsed as bibliographic information, not regular text. (It
1026will be used, for example, in the title of standalone LaTeX or HTML
1027output.) The block may contain just a title, a title and an author,
1028or all three elements. If you want to include an author but no
1029title, or a title and a date but no author, you need a blank line:
1038The title may occupy multiple lines, but continuation lines must
1039begin with leading space, thus:
1044If a document has multiple authors, the authors may be put on
1045separate lines with leading space, or separated by semicolons, or
1046both. So, all of the following are equivalent:
1051 % Author One; Author Two
1056The date must fit on one line.
1058All three metadata fields may contain standard inline formatting
1059(italics, links, footnotes, etc.).
1061Title blocks will always be parsed, but they will affect the output only
1062when the `--standalone` (`-s`) option is chosen. In HTML output, titles
1063will appear twice: once in the document head -- this is the title that
1064will appear at the top of the window in a browser -- and once at the
1065beginning of the document body. The title in the document head can have
1066an optional prefix attached (`--title-prefix` or `-T` option). The title
1067in the body appears as an H1 element with class "title", so it can be
1068suppressed or reformatted with CSS. If a title prefix is specified with
1069`-T` and no title block appears in the document, the title prefix will
1070be used by itself as the HTML title.
1072The man page writer extracts a title, man page section number, and
1073other header and footer information from the title line. The title
1074is assumed to be the first word on the title line, which may optionally
1075end with a (single-digit) section number in parentheses. (There should
1076be no space between the title and the parentheses.) Anything after
1077this is assumed to be additional footer and header text. A single pipe
1078character (`|`) should be used to separate the footer text from the header
1083will yield a man page with the title `PANDOC` and section 1.
1085 % PANDOC(1) Pandoc User Manuals
1087will also have "Pandoc User Manuals" in the footer.
1089 % PANDOC(1) Pandoc User Manuals | Version 4.0
1091will also have "Version 4.0" in the header.
1093Markdown in HTML blocks
1094-----------------------
1096While standard markdown leaves HTML blocks exactly as they are, Pandoc
1097treats text between HTML tags as markdown. Thus, for example, Pandoc
1103 <td>[a link](http://google.com)</td>
1111 <td><em>one</em></td>
1112 <td><a href="http://google.com">a link</a></td>
1116whereas `Markdown.pl` will preserve it as is.
1118There is one exception to this rule: text between `<script>` and
1119`</script>` tags is not interpreted as markdown.
1121This departure from standard markdown should make it easier to mix
1122markdown with HTML block elements. For example, one can surround
1123a block of markdown text with `<div>` tags without preventing it
1124from being interpreted as markdown.
1126Header identifiers in HTML
1127--------------------------
1129Each header element in pandoc's HTML output is given a unique
1130identifier. This identifier is based on the text of the header. To
1131derive the identifier from the header text,
1133 - Remove all formatting, links, etc.
1134 - Remove all punctuation, except underscores, hyphens, and periods.
1135 - Replace all spaces and newlines with hyphens.
1136 - Convert all alphabetic characters to lowercase.
1137 - Remove everything up to the first letter (identifiers may
1138 not begin with a number or punctuation mark).
1139 - If nothing is left after this, use the identifier `section`.
1144 ------------------------------------- ---------------------------
1145 Header identifiers in HTML `header-identifiers-in-html`
1146 *Dogs*?--in *my* house? `dogs--in-my-house`
1147 [HTML], [S5], or [RTF]? `html-s5-or-rtf`
1148 3. Applications `applications`
1151These rules should, in most cases, allow one to determine the identifier
1152from the header text. The exception is when several headers have the
1153same text; in this case, the first will get an identifier as described
1154above; the second will get the same identifier with `-1` appended; the
1155third with `-2`; and so on.
1157These identifiers are used to provide link targets in the table of
1158contents generated by the `--toc|--table-of-contents` option. They
1159also make it easy to provide links from one section of a document to
1160another. A link to this section, for example, might look like this:
1162 See the section on [header identifiers](#header-identifiers-in-html).
1164Note, however, that this method of providing links to sections works
1167If the `--section-divs` option is specified, then each section will
1168be wrapped in a `div`, and the identifier will be attached to the
1169enclosing `<div>` tag rather than the header itself. This allows entire
1170sections to be manipulated using javascript or treated differently in
1173Blank lines before headers and blockquotes
1174------------------------------------------
1176Standard markdown syntax does not require a blank line before a header
1177or blockquote. Pandoc does require this (except, of course, at the
1178beginning of the document). The reason for the requirement is that
1179it is all too easy for a `>` or `#` to end up at the beginning of a
1180line by accident (perhaps through line wrapping). Consider, for
1183 I like several of their flavors of ice cream: #22, for example, and
1189Anything between two $ characters will be treated as TeX math. The
1190opening $ must have a character immediately to its right, while the
1191closing $ must have a character immediately to its left. Thus,
1192`$20,000 and $30,000` won't parse as math. If for some reason
1193you need to enclose text in literal $ characters, backslash-escape
1194them and they won't be treated as math delimiters.
1196TeX math will be printed in all output formats. In Markdown,
1197reStructuredText, LaTeX, and ConTeXt output, it will appear verbatim
1198between $ characters.
1200In reStructuredText output, it will be rendered using an interpreted
1201text role `:math:`, as described
1202[here](http://www.american.edu/econ/itex2mml/mathhack.rst).
1204In Texinfo output, it will be rendered inside a `@math` command.
1206In groff man output, it will be rendered verbatim without $'s.
1208In MediaWiki output, it will be rendered inside `<math>` tags.
1210In RTF, Docbook, and OpenDocument output, it will be rendered, as far as
1211possible, using unicode characters, and will otherwise appear verbatim.
1212Unknown commands and symbols, and commands that cannot be dealt with
1213this way (like `\frac`), will be rendered verbatim. So the results may
1214be a mix of raw TeX code and properly rendered unicode math.
1216In HTML, Slidy, and S5 output, the way math is rendered will depend on the
1217command-line options selected:
12191. The default is to render TeX math as far as possible using unicode
1220 characters, as with RTF, Docbook, and OpenDocument output. Formulas
1221 are put inside a `span` with `class="math"`, so that they may be
1222 styled differently from the surrounding text if needed.
12242. If the `--latexmathml` option is used, TeX math will be displayed
1225 between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
1226 The [LaTeXMathML] script will be used to render it as formulas.
1227 (This trick does not work in all browsers, but it works in Firefox.
1228 In browsers that do not support LaTeXMathML, TeX math will appear
1229 verbatim between $ characters.)
12313. If the `--jsmath` option is used, TeX math will be put inside
1232 `<span>` tags (for inline math) or `<div>` tags (for display math)
1233 with class `math`. The [jsMath] script will be used to render
12364. If the `--mimetex` option is used, the [mimeTeX] CGI script will
1237 be called to generate images for each TeX formula. This should
1238 work in all browsers. The `--mimetex` option takes an optional URL
1239 as argument. If no URL is specified, it will be assumed that the
1240 mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
12425. If the `--gladtex` option is used, TeX formulas will be enclosed
1243 in `<eq>` tags in the HTML output. The resulting `htex` file may then
1244 be processed by [gladTeX], which will produce image files for each
1245 formula and an `html` file with links to these images. So, the
1248 pandoc -s --gladtex myfile.txt -o myfile.htex
1249 gladtex -d myfile-images myfile.htex
1250 # produces myfile.html and images in myfile-images
12526. If the `--webtex` option is used, TeX formulas will be converted
1253 to `<img>` tags that link to an external script that converts
1254 formulas to images. The formula will be URL-encoded and concatenated
1255 with the URL provided. If no URL is specified, the Google Chart
1256 API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).
1261For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and
1262`\renewcommand` definitions and apply the resulting macros to all LaTeX
1263math. So, for example, the following will work in all output formats,
1266 \newcommand{\tuple}[1]{\langle #1 \rangle}
1273Inline TeX commands will be preserved and passed unchanged to the
1274LaTeX and ConTeXt writers. Thus, for example, you can use LaTeX to
1275include BibTeX citations:
1277 This result was proved in \cite{jones.1967}.
1279Note that in LaTeX environments, like
1281 \begin{tabular}{|l|l|}\hline
1282 Age & Frequency \\ \hline
1285 36--45 & 22 \\ \hline
1288the material between the begin and end tags will be interpreted as raw
1289LaTeX, not as markdown.
1291Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
1294Producing HTML slide shows with Pandoc
1295======================================
1297You can use Pandoc to produce an HTML + javascript slide presentation
1298that can be viewed via a web browser. There are two ways to do this,
1299using [S5] or [Slidy].
1301Here's the markdown source for a simple slide show, `eating.txt`:
1317 --------------------------
1319 
1321To produce the slide show, simply type
1323 pandoc -w s5 -s eating.txt > eating.html
1327 pandoc -w slidy -s eating.txt > eating.html
1331A title page is constructed automatically from the document's title
1332block. Each level-one header and horizontal rule begins a new slide.
1334The file produced by pandoc with the `-s/--standalone` option embeds a
1335link to javascripts and CSS files, which are assumed to be available at
1336the relative path `ui/default` (for S5) or at the Slidy website at
1337`w3.org` (for Slidy). If the `--offline` option is specified, the
1338scripts and CSS will be included directly in the generated file, so that
1339it may be used offline.
1341You can change the style of the slides by putting customized CSS files
1342in `$DATADIR/s5/default` (for S5) or `$DATADIR/slidy` (for Slidy),
1343where `$DATADIR` is the user data directory (see `--data-dir`, above).
1344The originals may be found in pandoc's system data directory (generally
1345`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any
1346files it does not find in the user data directory.
1351By default, these writers produces lists that display "all at once."
1352If you want your lists to display incrementally (one item at a time),
1353use the `-i` option. If you want a particular list to depart from the
1354default (that is, to display incrementally without the `-i` option and
1355all at once with the `-i` option), put it in a block quote:
1360In this way incremental and nonincremental lists can be mixed in
1363Literate Haskell support
1364========================
1366If you append `+lhs` to an appropriate input or output format (`markdown`,
1367`rst`, or `latex` for input or output; `html` for output only), pandoc
1368will treat the document as literate Haskell source. This means that
1370 - In markdown input, "bird track" sections will be parsed as Haskell
1371 code rather than block quotations. Text between `\begin{code}`
1372 and `\end{code}` will also be treated as Haskell code.
1374 - In markdown output, code blocks with class `haskell` will be
1375 rendered using bird tracks, and block quotations will be
1376 indented one space, so they will not be treated as Haskell code.
1377 In addition, headers will be rendered setext-style (with underlines)
1378 rather than atx-style (with '#' characters). (This is because ghc
1379 treats '#' characters in column 1 as introducing line numbers.)
1381 - In restructured text input, "bird track" sections will be parsed
1384 - In restructured text output, code blocks with class `haskell` will
1385 be rendered using bird tracks.
1387 - In LaTeX input, text in `code` environments will be parsed as
1390 - In LaTeX output, code blocks with class `haskell` will be rendered
1391 inside `code` environments.
1393 - In HTML output, code blocks with class `haskell` will be rendered
1394 with class `literatehaskell` and bird tracks.
1398 pandoc -f markdown+lhs -t html
1400reads literate Haskell source formatted with markdown conventions and writes
1401ordinary HTML (without bird tracks).
1403 pandoc -f markdown+lhs -t html+lhs
1405writes HTML with the Haskell code in bird tracks, so it can be copied
1406and pasted as literate Haskell source.
1409[markdown]: http://daringfireball.net/projects/markdown/
1410[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
1411[S5]: http://meyerweb.com/eric/tools/s5/
1412[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
1413[HTML]: http://www.w3.org/TR/html40/
1414[LaTeX]: http://www.latex-project.org/
1415[ConTeXt]: http://www.pragma-ade.nl/
1416[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
1417[DocBook XML]: http://www.docbook.org/
1418[OpenDocument XML]: http://opendocument.xml.org/
1419[ODT]: http://en.wikipedia.org/wiki/OpenDocument
1420[MediaWiki markup]: http://www.mediawiki.org/wiki/Help:Formatting
1421[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html
1422[Haskell]: http://www.haskell.org/
1423[GNU Texinfo]: http://www.gnu.org/software/texinfo/
1424[EPUB]: http://www.idpf.org/
1425[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list