git.iko.soy/typeable/pandoc
on febbf5d help sign in
2073 lines 73 kB history raw
1% Pandoc User's Guide
2% John MacFarlane
3% July 30, 2011
5Synopsis
6========
8pandoc [*options*] [*input-file*]...
10Description
11===========
13Pandoc is a [Haskell] library for converting from one markup format to
14another, and a command-line tool that uses this library. It can read
15[markdown] and (subsets of) [Textile], [reStructuredText], [HTML],
16and [LaTeX]; and it can write plain text, [markdown], [reStructuredText],
17[XHTML], [HTML 5], [LaTeX], [LaTeX beamer], [ConTeXt], [RTF], [DocBook XML],
18[OpenDocument XML], [ODT], [GNU Texinfo], [MediaWiki markup], [EPUB],
19[Textile], [groff man] pages, [Emacs Org-Mode], [AsciiDoc], and [Slidy],
20[DZSlides], or [S5] HTML slide shows.
22Pandoc's enhanced version of markdown includes syntax for footnotes,
23tables, flexible ordered lists, definition lists, delimited code blocks,
24superscript, subscript, strikeout, title blocks, automatic tables of
25contents, embedded LaTeX math, citations, and markdown inside HTML block
26elements. (These enhancements, described below under
27[Pandoc's markdown](#pandocs-markdown), can be disabled using the `--strict`
28option.)
30In contrast to most existing tools for converting markdown to HTML, which
31use regex substitutions, Pandoc has a modular design: it consists of a
32set of readers, which parse text in a given format and produce a native
33representation of the document, and a set of writers, which convert
34this native representation into a target format. Thus, adding an input
35or output format requires only adding a reader or writer.
37Using Pandoc
38------------
40If no *input-file* is specified, input is read from *stdin*.
41Otherwise, the *input-files* are concatenated (with a blank
42line between each) and used as input. Output goes to *stdout* by
43default (though output to *stdout* is disabled for the `odt` and
44`epub` output formats). For output to a file, use the `-o` option:
46 pandoc -o output.html input.txt
48Instead of a file, an absolute URI may be given. In this case
49pandoc will fetch the content using HTTP:
51 pandoc -f html -t markdown http://www.fsf.org
53If multiple input files are given, `pandoc` will concatenate them all (with
54blank lines between them) before parsing.
56The format of the input and output can be specified explicitly using
57command-line options. The input format can be specified using the
58`-r/--read` or `-f/--from` options, the output format using the
59`-w/--write` or `-t/--to` options. Thus, to convert `hello.txt` from
60markdown to LaTeX, you could type:
62 pandoc -f markdown -t latex hello.txt
64To convert `hello.html` from html to markdown:
66 pandoc -f html -t markdown hello.html
68Supported output formats are listed below under the `-t/--to` option.
69Supported input formats are listed below under the `-f/--from` option. Note
70that the `rst`, `textile`, `latex`, and `html` readers are not complete;
71there are some constructs that they do not parse.
73If the input or output format is not specified explicitly, `pandoc`
74will attempt to guess it from the extensions of
75the input and output filenames. Thus, for example,
77 pandoc -o hello.tex hello.txt
79will convert `hello.txt` from markdown to LaTeX. If no output file
80is specified (so that output goes to *stdout*), or if the output file's
81extension is unknown, the output format will default to HTML.
82If no input file is specified (so that input comes from *stdin*), or
83if the input files' extensions are unknown, the input format will
84be assumed to be markdown unless explicitly specified.
86Pandoc uses the UTF-8 character encoding for both input and output.
87If your local character encoding is not UTF-8, you
88should pipe input and output through `iconv`:
90 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
92Wrappers
93========
95`markdown2pdf`
96--------------
98The standard Pandoc installation includes `markdown2pdf`, a wrapper
99around `pandoc` and `pdflatex` that produces PDFs directly from markdown
100sources. The default behavior of `markdown2pdf` is to create a file with
101the same base name as the first argument and the extension `pdf`; thus,
102for example,
104 markdown2pdf sample.txt endnotes.txt
106will produce `sample.pdf`. An output file
107name can be specified explicitly using the `-o` option:
109 markdown2pdf -o book.pdf chap1 chap2
111If no input file is specified, input will be taken from *stdin*.
112All of `pandoc`'s options will work with `markdown2pdf` as well.
114`markdown2pdf` assumes that `pdflatex` is in the path. It also
115assumes that the following LaTeX packages are available:
116`unicode`, `fancyhdr` (if you have verbatim text in footnotes),
117`graphicx` (if you use images), `array` (if you use tables),
118and `ulem` (if you use strikeout text). If they are not already
119included in your LaTeX distribution, you can get them from
120[CTAN]. A full [TeX Live] or [MacTeX] distribution will have all of
121these packages.
123`hsmarkdown`
124------------
126A user who wants a drop-in replacement for `Markdown.pl` may create
127a symbolic link to the `pandoc` executable called `hsmarkdown`. When
128invoked under the name `hsmarkdown`, `pandoc` will behave as if the
129`--strict` flag had been selected, and no command-line options will be
130recognized. However, this approach does not work under Cygwin, due to
131problems with its simulation of symbolic links.
133[Cygwin]: http://www.cygwin.com/
134[`iconv`]: http://www.gnu.org/software/libiconv/
135[CTAN]: http://www.ctan.org "Comprehensive TeX Archive Network"
136[TeX Live]: http://www.tug.org/texlive/
137[MacTeX]: http://www.tug.org/mactex/
139Options
140=======
142`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*
143: Specify input format. *FORMAT* can be `native` (native Haskell),
144 `json` (JSON version of native AST), `markdown` (markdown),
145 `textile` (Textile), `rst` (reStructuredText), `html` (HTML),
146 or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`,
147 or `latex`, the input will be treated as literate Haskell source:
148 see [Literate Haskell support](#literate-haskell-support),
149 below.
151`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
152: Specify output format. *FORMAT* can be `native` (native Haskell),
153 `json` (JSON version of native AST), `plain` (plain text),
154 `markdown` (markdown), `rst` (reStructuredText), `html` (XHTML 1),
155 `html5` (HTML 5), `latex` (LaTeX), `beamer` (LaTeX beamer), `context`
156 (ConTeXt), `man` (groff man), `mediawiki` (MediaWiki markup), `textile`
157 (Textile), `org` (Emacs Org-Mode), `texinfo` (GNU Texinfo), `docbook`
158 (DocBook XML), `opendocument` (OpenDocument XML), `odt` (OpenOffice text
159 document), `epub` (EPUB book), `asciidoc` (AsciiDoc), `slidy` (Slidy HTML
160 and javascript slide show), `dzslides` (HTML5 + javascript slide show),
161 `s5` (S5 HTML and javascript slide show), or `rtf` (rich text format).
162 Note that `odt` and `epub` output will not be directed to *stdout*;
163 an output filename must be specified using the `-o/--output` option.
164 If `+lhs` is appended to `markdown`, `rst`, `latex`, `html`, or `html5`,
165 the output will be rendered as literate Haskell source: see [Literate
166 Haskell support](#literate-haskell-support), below.
168`-s`, `--standalone`
169: Produce output with an appropriate header and footer (e.g. a
170 standalone HTML, LaTeX, or RTF file, not a fragment).
172`-o` *FILE*, `--output=`*FILE*
173: Write output to *FILE* instead of *stdout*. If *FILE* is
174 `-`, output will go to *stdout*. (Exception: if the output
175 format is `odt` or `epub`, output to stdout is disabled.)
177`-p`, `--preserve-tabs`
178: Preserve tabs instead of converting them to spaces (the default).
180`--tab-stop=`*NUMBER*
181: Specify the number of spaces per tab (default is 4).
183`--strict`
184: Use strict markdown syntax, with no pandoc extensions or variants.
185 When the input format is HTML, this means that constructs that have no
186 equivalents in standard markdown (e.g. definition lists or strikeout
187 text) will be parsed as raw HTML.
189`--normalize`
190: Normalize the document after reading: merge adjacent
191 `Str` or `Emph` elements, for example, and remove repeated `Space`s.
193`--reference-links`
194: Use reference-style links, rather than inline links, in writing markdown
195 or reStructuredText. By default inline links are used.
197`-R`, `--parse-raw`
198: Parse untranslatable HTML codes and LaTeX environments as raw HTML
199 or LaTeX, instead of ignoring them. Affects only HTML and LaTeX
200 input. Raw HTML can be printed in markdown, reStructuredText, HTML, Slidy,
201 DZSlides, and S5 output; raw LaTeX can be printed in markdown,
202 reStructuredText, LaTeX, and ConTeXt output. The default is for the
203 readers to omit untranslatable HTML codes and LaTeX environments.
204 (The LaTeX reader does pass through untranslatable LaTeX *commands*,
205 even if `-R` is not specified.)
207`-S`, `--smart`
208: Produce typographically correct output, converting straight quotes
209 to curly quotes, `---` and `--` to dashes, and `...` to ellipses.
210 Nonbreaking spaces are inserted after certain abbreviations, such
211 as "Mr." (Note: This option is significant only when the input format is
212 `markdown` or `textile`. It is selected automatically when the input
213 format is `textile` or the output format is `latex` or `context`.)
215`-5`, `--html5`
216: Produce HTML5 instead of HTML4. This option has no effect for writers
217 other than `html`. (*Deprecated:* Use the `html5` output format instead.)
219`--no-highlight`
220: Disables syntax highlighting for code blocks and inlines, even when
221 a language attribute is given.
223`--highlight-style`=*STYLE*
224: Specifies the coloring style to be used in highlighted source code.
225 Options are `pygments` (the default), `kate`, `monochrome`,
226 `espresso`, `haddock`, and `tango`.
228`-m` [*URL*], `--latexmathml`[=*URL*]
229: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.
230 To insert a link to a local copy of the `LaTeXMathML.js` script,
231 provide a *URL*. If no *URL* is provided, the contents of the
232 script will be inserted directly into the HTML header, preserving
233 portability at the price of efficiency. If you plan to use math on
234 several pages, it is much better to link to a copy of the script,
235 so it can be cached.
237`--mathml`[=*URL*]
238: Convert TeX math to MathML. In standalone mode, a small javascript
239 (or a link to such a script if a *URL* is supplied) will be inserted that
240 allows the MathML to be viewed on some browsers.
242`--jsmath`[=*URL*]
243: Use [jsMath] to display embedded TeX math in HTML output.
244 The *URL* should point to the jsMath load script (e.g.
245 `jsMath/easy/load.js`); if provided, it will be linked to in
246 the header of standalone HTML documents. If a *URL* is not provided,
247 no link to the jsMath load script will be inserted; it is then
248 up to the author to provide such a link in the HTML template.
250`--mathjax`[=*URL*]
251: Use [MathJax] to display embedded TeX math in HTML output.
252 The *URL* should point to the `MathJax.js` load script.
253 If a *URL* is not provided, a link to the MathJax CDN will
254 be inserted.
256`--gladtex`
257: Enclose TeX math in `<eq>` tags in HTML output. These can then
258 be processed by [gladTeX] to produce links to images of the typeset
259 formulas.
261`--mimetex`[=*URL*]
262: Render TeX math using the [mimeTeX] CGI script. If *URL* is not
263 specified, it is assumed that the script is at `/cgi-bin/mimetex.cgi`.
265`--webtex`[=*URL*]
266: Render TeX formulas using an external script that converts TeX
267 formulas to images. The formula will be concatenated with the URL
268 provided. If *URL* is not specified, the Google Chart API will be used.
270`-i`, `--incremental`
271: Make list items in Slidy, DZSlides or S5 display incrementally (one by one).
272 The default is for lists to be displayed all at once.
274`--self-contained`
275: Produce a standalone HTML file with no external dependencies, using
276 `data:` URIs to incorporate the contents of linked scripts, stylesheets,
277 images, and videos. The resulting file should be "self-contained,"
278 in the sense that it needs no external files and no net access to be
279 displayed properly by a browser. This option works only with HTML output
280 formats, including `html`, `html5`, `html+lhs`, `html5+lhs`, `s5`,
281 `slidy`, and `dzslides`. Scripts, images, and stylesheets at absolute URLs
282 will be downloaded; those at relative URLs will be sought first relative
283 to the working directory, then relative to the user data directory (see
284 `--data-dir`), and finally relative to pandoc's default data directory.
286`--offline`
287: Deprecated synonym for `--self-contained`.
289`--chapters`
290: Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook
291 output. When the LaTeX template uses the report, book, or
292 memoir class, this option is implied.
294`-N`, `--number-sections`
295: Number section headings in LaTeX, ConTeXt, or HTML output.
296 By default, sections are not numbered.
298`--listings`
299: Use listings package for LaTeX code blocks
301`--section-divs`
302: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),
303 and attach identifiers to the enclosing `<div>` (or `<section>`)
304 rather than the header itself.
305 See [Section identifiers](#header-identifiers-in-html), below.
307`--no-wrap`
308: Disable text wrapping in output. By default, text is wrapped
309 appropriately for the output format.
311`--columns`=*NUMBER*
312: Specify length of lines in characters (for text wrapping).
314`--email-obfuscation=`*none|javascript|references*
315: Specify a method for obfuscating `mailto:` links in HTML documents.
316 *none* leaves `mailto:` links as they are. *javascript* obfuscates
317 them using javascript. *references* obfuscates them by printing their
318 letters as decimal or hexadecimal character references.
319 If `--strict` is specified, *references* is used regardless of the
320 presence of this option.
322`--id-prefix`=*STRING*
323: Specify a prefix to be added to all automatically generated identifiers
324 in HTML output. This is useful for preventing duplicate identifiers
325 when generating fragments to be included in other pages.
327`--indented-code-classes=`*CLASSES*
328: Specify classes to use for indented code blocks--for example,
329 `perl,numberLines` or `haskell`. Multiple classes may be separated
330 by spaces or commas.
332`--toc`, `--table-of-contents`
333: Include an automatically generated table of contents (or, in
334 the case of `latex`, `context`, and `rst`, an instruction to create
335 one) in the output document. This option has no effect on `man`,
336 `docbook`, `slidy`, or `s5` output.
338`--base-header-level=`*NUMBER*
339: Specify the base level for headers (defaults to 1).
341`--template=`*FILE*
342: Use *FILE* as a custom template for the generated document. Implies
343 `--standalone`. See [Templates](#templates) below for a description
344 of template syntax. If no extension is specified, an extension
345 corresponding to the writer will be added, so that `--template=special`
346 looks for `special.html` for HTML output. If the template is not
347 found, pandoc will search for it in the user data directory
348 (see `--data-dir`). If this option is not used, a default
349 template appropriate for the output format will be used (see
350 `-D/--print-default-template`).
352`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
353: Set the template variable *KEY* to the value *VAL* when rendering the
354 document in standalone mode. This is generally only useful when the
355 `--template` option is used to specify a custom template, since
356 pandoc automatically sets the variables used in the default
357 templates.
359`-c` *URL*, `--css=`*URL*
360: Link to a CSS style sheet.
362`-H` *FILE*, `--include-in-header=`*FILE*
363: Include contents of *FILE*, verbatim, at the end of the header.
364 This can be used, for example, to include special
365 CSS or javascript in HTML documents. This option can be used
366 repeatedly to include multiple files in the header. They will be
367 included in the order specified. Implies `--standalone`.
369`-B` *FILE*, `--include-before-body=`*FILE*
370: Include contents of *FILE*, verbatim, at the beginning of the
371 document body (e.g. after the `<body>` tag in HTML, or the
372 `\begin{document}` command in LaTeX). This can be used to include
373 navigation bars or banners in HTML documents. This option can be
374 used repeatedly to include multiple files. They will be included in
375 the order specified. Implies `--standalone`.
377`-A` *FILE*, `--include-after-body=`*FILE*
378: Include contents of *FILE*, verbatim, at the end of the document
379 body (before the `</body>` tag in HTML, or the
380 `\end{document}` command in LaTeX). This option can be be used
381 repeatedly to include multiple files. They will be included in the
382 order specified. Implies `--standalone`.
384`--reference-odt=`*FILE*
385: Use the specified file as a style reference in producing an ODT.
386 For best results, the reference ODT should be a modified version
387 of an ODT produced using pandoc. The contents of the reference ODT
388 are ignored, but its stylesheets are used in the new ODT. If no
389 reference ODT is specified on the command line, pandoc will look
390 for a file `reference.odt` in the user data directory (see
391 `--data-dir`). If this is not found either, sensible defaults will be
392 used.
394`--epub-stylesheet=`*FILE*
395: Use the specified CSS file to style the EPUB. If no stylesheet
396 is specified, pandoc will look for a file `epub.css` in the
397 user data directory (see `--data-dir`, below). If it is not
398 found there, sensible defaults will be used.
400`--epub-cover-image=`*FILE*
401: Use the specified image as the EPUB cover. It is recommended
402 that the image be less than 1000px in width and height.
404`--epub-metadata=`*FILE*
405: Look in the specified XML file for metadata for the EPUB.
406 The file should contain a series of Dublin Core elements,
407 as documented at <http://dublincore.org/documents/dces/>.
408 For example:
410 <dc:rights>Creative Commons</dc:rights>
411 <dc:language>es-AR</dc:language>
413 By default, pandoc will include the following metadata elements:
414 `<dc:title>` (from the document title), `<dc:creator>` (from the
415 document authors), `<dc:language>` (from the locale), and
416 `<dc:identifier id="BookId">` (a randomly generated UUID). Any of
417 these may be overridden by elements in the metadata file.
419`-D` *FORMAT*, `--print-default-template=`*FORMAT*
420: Print the default template for an output *FORMAT*. (See `-t`
421 for a list of possible *FORMAT*s.)
423`-T` *STRING*, `--title-prefix=`*STRING*
424: Specify *STRING* as a prefix at the beginning of the title
425 that appears in the HTML header (but not in the title as it
426 appears at the beginning of the HTML body). Implies
427 `--standalone`.
429`--bibliography=`*FILE*
430: Specify bibliography database to be used in resolving
431 citations. The database type will be determined from the
432 extension of *FILE*, which may be `.mods` (MODS format),
433 `.bib` (BibTeX/BibLaTeX format),
434 `.ris` (RIS format), `.enl` (EndNote format),
435 `.xml` (EndNote XML format), `.wos` (ISI format),
436 `.medline` (MEDLINE format), `.copac` (Copac format),
437 or `.json` (citeproc JSON). If you want to use multiple
438 bibliographies, just use this option repeatedly.
440`--csl=`*FILE*
441: Specify [CSL] style to be used in formatting citations and
442 the bibliography. If *FILE* is not found, pandoc will look
443 for it in
445 $HOME/.csl
447 in unix and
449 C:\Documents And Settings\USERNAME\Application Data\csl
451 in Windows. If the `--csl` option is not specified, pandoc
452 will use a default style: either `default.csl` in the
453 user data directory (see `--data-dir`), or, if that is
454 not present, the Chicago author-date style.
456`--citation-abbreviations=`*FILE*
457: Specify a file containing abbreviations for journal titles and
458 other bibliographic fields (indicated by setting `form="short"`
459 in the CSL node for the field). The format is described at
460 <http://citationstylist.org/2011/10/19/abbreviations-for-zotero-test-release/>.
461 Here is a short example:
463 { "default": {
464 "container-title": {
465 "Lloyd's Law Reports": "Lloyd's Rep",
466 "Estates Gazette": "EG",
467 "Scots Law Times": "SLT"
468 }
469 }
470 }
472`--natbib`
473: Use natbib for citations in LaTeX output.
475`--biblatex`
476: Use biblatex for citations in LaTeX output.
478`--data-dir=`*DIRECTORY*
479: Specify the user data directory to search for pandoc data files.
480 If this option is not specified, the default user data directory
481 will be used:
483 $HOME/.pandoc
485 in unix and
487 C:\Documents And Settings\USERNAME\Application Data\pandoc
489 in Windows. A `reference.odt`, `epub.css`, `templates` directory,
490 or `s5` directory placed in this directory will override pandoc's
491 normal defaults.
493`--dump-args`
494: Print information about command-line arguments to *stdout*, then exit.
495 This option is intended primarily for use in wrapper scripts.
496 The first line of output contains the name of the output file specified
497 with the `-o` option, or `-` (for *stdout*) if no output file was
498 specified. The remaining lines contain the command-line arguments,
499 one per line, in the order they appear. These do not include regular
500 Pandoc options and their arguments, but do include any options appearing
501 after a `--` separator at the end of the line.
503`--ignore-args`
504: Ignore command-line arguments (for use in wrapper scripts).
505 Regular Pandoc options are not ignored. Thus, for example,
507 pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
509 is equivalent to
511 pandoc -o foo.html -s
513`-v`, `--version`
514: Print version.
516`-h`, `--help`
517: Show usage message.
519[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/
520[jsMath]: http://www.math.union.edu/~dpvc/jsmath/
521[MathJax]: http://www.mathjax.org/
522[gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html
523[mimeTeX]: http://www.forkosh.com/mimetex.html
524[CSL]: http://CitationStyles.org
526Templates
527=========
529When the `-s/--standalone` option is used, pandoc uses a template to
530add header and footer material that is needed for a self-standing
531document. To see the default template that is used, just type
533 pandoc -D FORMAT
535where `FORMAT` is the name of the output format. A custom template
536can be specified using the `--template` option. You can also override
537the system default templates for a given output format `FORMAT`
538by putting a file `templates/default.FORMAT` in the user data
539directory (see `--data-dir`, above).
541Templates may contain *variables*. Variable names are sequences of
542alphanumerics, `-`, and `_`, starting with a letter. A variable name
543surrounded by `$` signs will be replaced by its value. For example,
544the string `$title$` in
546 <title>$title$</title>
548will be replaced by the document title.
550To write a literal `$` in a template, use `$$`.
552Some variables are set automatically by pandoc. These vary somewhat
553depending on the output format, but include:
555`header-includes`
556: contents specified by `-H/--include-in-header` (may have multiple
557 values)
558`toc`
559: non-null value if `--toc/--table-of-contents` was specified
560`include-before`
561: contents specified by `-B/--include-before-body` (may have
562 multiple values)
563`include-after`
564: contents specified by `-A/--include-after-body` (may have
565 multiple values)
566`body`
567: body of document
568`title`
569: title of document, as specified in title block
570`author`
571: author of document, as specified in title block (may have
572 multiple values)
573`date`
574: date of document, as specified in title block
575`lang`
576: language code for HTML or LaTeX documents
577`slidy-url`
578: base URL for Slidy documents (defaults to
579 `http://www.w3.org/Talks/Tools/Slidy2`)
580`s5-url`
581: base URL for S5 documents (defaults to `ui/default`)
582`font-size`
583: font size (10pt, 11pt, 12pt) for LaTeX and beamer documents
584`documentclass`
585: document class for LaTeX documents
586`theme`
587: theme for beamer documents
588`colortheme`
589: colortheme for beamer documents
591Variables may be set at the command line using the `-V/--variable`
592option. This allows users to include custom variables in their
593templates.
595Templates may contain conditionals. The syntax is as follows:
597 $if(variable)$
598 X
599 $else$
600 Y
601 $endif$
603This will include `X` in the template if `variable` has a non-null
604value; otherwise it will include `Y`. `X` and `Y` are placeholders for
605any valid template text, and may include interpolated variables or other
606conditionals. The `$else$` section may be omitted.
608When variables can have multiple values (for example, `author` in
609a multi-author document), you can use the `$for$` keyword:
611 $for(author)$
612 <meta name="author" content="$author$" />
613 $endfor$
615You can optionally specify a separator to be used between
616consecutive items:
618 $for(author)$$author$$sep$, $endfor$
620If you use custom templates, you may need to revise them as pandoc
621changes. We recommend tracking the changes in the default templates,
622and modifying your custom templates accordingly. An easy way to do this
623is to fork the pandoc-templates repository
624(<http://github.com/jgm/pandoc-templates>) and merge in changes after each
625pandoc release.
627Pandoc's markdown
628=================
630Pandoc understands an extended and slightly revised version of
631John Gruber's [markdown] syntax. This document explains the syntax,
632noting differences from standard markdown. Except where noted, these
633differences can be suppressed by specifying the `--strict` command-line
634option.
636Philosophy
637----------
639Markdown is designed to be easy to write, and, even more importantly,
640easy to read:
642> A Markdown-formatted document should be publishable as-is, as plain
643> text, without looking like it's been marked up with tags or formatting
644> instructions.
645> -- [John Gruber](http://daringfireball.net/projects/markdown/syntax#philosophy)
647This principle has guided pandoc's decisions in finding syntax for
648tables, footnotes, and other extensions.
650There is, however, one respect in which pandoc's aims are different
651from the original aims of markdown. Whereas markdown was originally
652designed with HTML generation in mind, pandoc is designed for multiple
653output formats. Thus, while pandoc allows the embedding of raw HTML,
654it discourages it, and provides other, non-HTMLish ways of representing
655important document elements like definition lists, tables, mathematics, and
656footnotes.
658Paragraphs
659----------
661A paragraph is one or more lines of text followed by one or more blank line.
662Newlines are treated as spaces, so you can reflow your paragraphs as you like.
663If you need a hard line break, put two or more spaces at the end of a line,
664or type a backslash followed by a newline.
666Headers
667-------
669There are two kinds of headers, Setext and atx.
671### Setext-style headers ###
673A setext-style header is a line of text "underlined" with a row of `=` signs
674(for a level one header) of `-` signs (for a level two header):
676 A level-one header
677 ==================
679 A level-two header
680 ------------------
682The header text can contain inline formatting, such as emphasis (see
683[Inline formatting](#inline-formatting), below).
686### Atx-style headers ###
688An Atx-style header consists of one to six `#` signs and a line of
689text, optionally followed by any number of `#` signs. The number of
690`#` signs at the beginning of the line is the header level:
692 ## A level-two header
694 ### A level-three header ###
696As with setext-style headers, the header text can contain formatting:
698 # A level-one header with a [link](/url) and *emphasis*
700Standard markdown syntax does not require a blank line before a header.
701Pandoc does require this (except, of course, at the beginning of the
702document). The reason for the requirement is that it is all too easy for a
703`#` to end up at the beginning of a line by accident (perhaps through line
704wrapping). Consider, for example:
706 I like several of their flavors of ice cream:
707 #22, for example, and #5.
710### Header identifiers in HTML ###
712*Pandoc extension*.
714Each header element in pandoc's HTML output is given a unique
715identifier. This identifier is based on the text of the header. To
716derive the identifier from the header text,
718 - Remove all formatting, links, etc.
719 - Remove all punctuation, except underscores, hyphens, and periods.
720 - Replace all spaces and newlines with hyphens.
721 - Convert all alphabetic characters to lowercase.
722 - Remove everything up to the first letter (identifiers may
723 not begin with a number or punctuation mark).
724 - If nothing is left after this, use the identifier `section`.
726Thus, for example,
728 Header Identifier
729 ------------------------------- ----------------------------
730 Header identifiers in HTML `header-identifiers-in-html`
731 *Dogs*?--in *my* house? `dogs--in-my-house`
732 [HTML], [S5], or [RTF]? `html-s5-or-rtf`
733 3. Applications `applications`
734 33 `section`
736These rules should, in most cases, allow one to determine the identifier
737from the header text. The exception is when several headers have the
738same text; in this case, the first will get an identifier as described
739above; the second will get the same identifier with `-1` appended; the
740third with `-2`; and so on.
742These identifiers are used to provide link targets in the table of
743contents generated by the `--toc|--table-of-contents` option. They
744also make it easy to provide links from one section of a document to
745another. A link to this section, for example, might look like this:
747 See the section on
748 [header identifiers](#header-identifiers-in-html).
750Note, however, that this method of providing links to sections works
751only in HTML.
753If the `--section-divs` option is specified, then each section will
754be wrapped in a `div` (or a `section`, if `--html5` was specified),
755and the identifier will be attached to the enclosing `<div>`
756(or `<section>`) tag rather than the header itself. This allows entire
757sections to be manipulated using javascript or treated differently in
758CSS.
761Block quotations
762----------------
764Markdown uses email conventions for quoting blocks of text.
765A block quotation is one or more paragraphs or other block elements
766(such as lists or headers), with each line preceded by a `>` character
767and a space. (The `>` need not start at the left margin, but it should
768not be indented more than three spaces.)
770 > This is a block quote. This
771 > paragraph has two lines.
772 >
773 > 1. This is a list inside a block quote.
774 > 2. Second item.
776A "lazy" form, which requires the `>` character only on the first
777line of each block, is also allowed:
779 > This is a block quote. This
780 paragraph has two lines.
782 > 1. This is a list inside a block quote.
783 2. Second item.
785Among the block elements that can be contained in a block quote are
786other block quotes. That is, block quotes can be nested:
788 > This is a block quote.
789 >
790 > > A block quote within a block quote.
792Standard markdown syntax does not require a blank line before a block
793quote. Pandoc does require this (except, of course, at the beginning of the
794document). The reason for the requirement is that it is all too easy for a
795`>` to end up at the beginning of a line by accident (perhaps through line
796wrapping). So, unless `--strict` is used, the following does not produce
797a nested block quote in pandoc:
799 > This is a block quote.
800 >> Nested.
803Verbatim (code) blocks
804----------------------
806### Indented code blocks ###
808A block of text indented four spaces (or one tab) is treated as verbatim
809text: that is, special characters do not trigger special formatting,
810and all spaces and line breaks are preserved. For example,
812 if (a > 3) {
813 moveShip(5 * gravity, DOWN);
814 }
816The initial (four space or one tab) indentation is not considered part
817of the verbatim text, and is removed in the output.
819Note: blank lines in the verbatim text need not begin with four spaces.
822### Delimited code blocks ###
824*Pandoc extension*.
826In addition to standard indented code blocks, Pandoc supports
827*delimited* code blocks. These begin with a row of three or more
828tildes (`~`) and end with a row of tildes that must be at least
829as long as the starting row. Everything between the tilde-lines
830is treated as code. No indentation is necessary:
832 ~~~~~~~
833 if (a > 3) {
834 moveShip(5 * gravity, DOWN);
835 }
836 ~~~~~~~
838Like regular code blocks, delimited code blocks must be separated
839from surrounding text by blank lines.
841If the code itself contains a row of tildes, just use a longer
842row of tildes at the start and end:
844 ~~~~~~~~~~~~~~~~
845 ~~~~~~~~~~
846 code including tildes
847 ~~~~~~~~~~
848 ~~~~~~~~~~~~~~~~
850Optionally, you may specify the language of the code block using
851this syntax:
853 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines}
854 qsort [] = []
855 qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
856 qsort (filter (>= x) xs)
857 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
859Some output formats can use this information to do syntax highlighting.
860Currently, the only output formats that uses this information are HTML
861and LaTeX. If highlighting is supported for your output format and language,
862then the code block above will appear highlighted, with numbered lines. (To
863see which languages are supported, do `pandoc --version`.) Otherwise, the code
864block above will appear as follows:
866 <pre class="haskell">
867 <code>
868 ...
869 </code>
870 </pre>
872To prevent all highlighting, use the `--no-highlight` flag.
873To set the highlighting style, use `--highlight-style`.
875Lists
876-----
878### Bullet lists ###
880A bullet list is a list of bulleted list items. A bulleted list
881item begins with a bullet (`*`, `+`, or `-`). Here is a simple
882example:
884 * one
885 * two
886 * three
888This will produce a "compact" list. If you want a "loose" list, in which
889each item is formatted as a paragraph, put spaces between the items:
891 * one
893 * two
895 * three
897The bullets need not be flush with the left margin; they may be
898indented one, two, or three spaces. The bullet must be followed
899by whitespace.
901List items look best if subsequent lines are flush with the first
902line (after the bullet):
904 * here is my first
905 list item.
906 * and my second.
908But markdown also allows a "lazy" format:
910 * here is my first
911 list item.
912 * and my second.
914### The four-space rule ###
916A list item may contain multiple paragraphs and other block-level
917content. However, subsequent paragraphs must be preceded by a blank line
918and indented four spaces or a tab. The list will look better if the first
919paragraph is aligned with the rest:
921 * First paragraph.
923 Continued.
925 * Second paragraph. With a code block, which must be indented
926 eight spaces:
928 { code }
930List items may include other lists. In this case the preceding blank
931line is optional. The nested list must be indented four spaces or
932one tab:
934 * fruits
935 + apples
936 - macintosh
937 - red delicious
938 + pears
939 + peaches
940 * vegetables
941 + brocolli
942 + chard
944As noted above, markdown allows you to write list items "lazily," instead of
945indenting continuation lines. However, if there are multiple paragraphs or
946other blocks in a list item, the first line of each must be indented.
948 + A lazy, lazy, list
949 item.
951 + Another one; this looks
952 bad but is legal.
954 Second paragraph of second
955 list item.
957**Note:** Although the four-space rule for continuation paragraphs
958comes from the official [markdown syntax guide], the reference implementation,
959`Markdown.pl`, does not follow it. So pandoc will give different results than
960`Markdown.pl` when authors have indented continuation paragraphs fewer than
961four spaces.
963The [markdown syntax guide] is not explicit whether the four-space
964rule applies to *all* block-level content in a list item; it only
965mentions paragraphs and code blocks. But it implies that the rule
966applies to all block-level content (including nested lists), and
967pandoc interprets it that way.
969 [markdown syntax guide]:
970 http://daringfireball.net/projects/markdown/syntax#list
972### Ordered lists ###
974Ordered lists work just like bulleted lists, except that the items
975begin with enumerators rather than bullets.
977In standard markdown, enumerators are decimal numbers followed
978by a period and a space. The numbers themselves are ignored, so
979there is no difference between this list:
981 1. one
982 2. two
983 3. three
985and this one:
987 5. one
988 7. two
989 1. three
991*Pandoc extension*.
993Unlike standard markdown, Pandoc allows ordered list items to be marked
994with uppercase and lowercase letters and roman numerals, in addition to
995arabic numerals. List markers may be enclosed in parentheses or followed by a
996single right-parentheses or period. They must be separated from the
997text that follows by at least one space, and, if the list marker is a
998capital letter with a period, by at least two spaces.[^2]
1000[^2]: The point of this rule is to ensure that normal paragraphs
1001 starting with people's initials, like
1003 B. Russell was an English philosopher.
1005 do not get treated as list items.
1007 This rule will not prevent
1009 (C) 2007 Joe Smith
1011 from being interpreted as a list item. In this case, a backslash
1012 escape can be used:
1014 (C\) 2007 Joe Smith
1016Pandoc also pays attention to the type of list marker used, and to the
1017starting number, and both of these are preserved where possible in the
1018output format. Thus, the following yields a list with numbers followed
1019by a single parenthesis, starting with 9, and a sublist with lowercase
1020roman numerals:
1022 9) Ninth
1023 10) Tenth
1024 11) Eleventh
1025 i. subone
1026 ii. subtwo
1027 iii. subthree
1029Note that Pandoc pays attention only to the *starting* marker in a list.
1030So, the following yields a list numbered sequentially starting from 2:
1032 (2) Two
1033 (5) Three
1034 1. Four
1035 * Five
1037If default list markers are desired, use `#.`:
1039 #. one
1040 #. two
1041 #. three
1044### Definition lists ###
1046*Pandoc extension*.
1048Pandoc supports definition lists, using a syntax inspired by
1049[PHP Markdown Extra] and [reStructuredText]:[^3]
1051 Term 1
1053 : Definition 1
1055 Term 2 with *inline markup*
1057 : Definition 2
1059 { some code, part of Definition 2 }
1061 Third paragraph of definition 2.
1063Each term must fit on one line, which may optionally be followed by
1064a blank line, and must be followed by one or more definitions.
1065A definition begins with a colon or tilde, which may be indented one
1066or two spaces. The body of the definition (including the first line,
1067aside from the colon or tilde) should be indented four spaces. A term may have
1068multiple definitions, and each definition may consist of one or more block
1069elements (paragraph, code block, list, etc.), each indented four spaces or one
1070tab stop.
1072If you leave space after the definition (as in the example above),
1073the blocks of the definitions will be considered paragraphs. In some
1074output formats, this will mean greater spacing between term/definition
1075pairs. For a compact definition list, do not leave space between the
1076definition and the next term:
1078 Term 1
1079 ~ Definition 1
1080 Term 2
1081 ~ Definition 2a
1082 ~ Definition 2b
1084[^3]: I have also been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).
1086[PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
1089### Numbered example lists ###
1091*Pandoc extension*.
1093The special list marker `@` can be used for sequentially numbered
1094examples. The first list item with a `@` marker will be numbered '1',
1095the next '2', and so on, throughout the document. The numbered examples
1096need not occur in a single list; each new list using `@` will take up
1097where the last stopped. So, for example:
1099 (@) My first example will be numbered (1).
1100 (@) My second example will be numbered (2).
1102 Explanation of examples.
1104 (@) My third example will be numbered (3).
1106Numbered examples can be labeled and referred to elsewhere in the
1107document:
1109 (@good) This is a good example.
1111 As (@good) illustrates, ...
1113The label can be any string of alphanumeric characters, underscores,
1114or hyphens.
1117### Compact and loose lists ###
1119Pandoc behaves differently from `Markdown.pl` on some "edge
1120cases" involving lists. Consider this source:
1122 + First
1123 + Second:
1124 - Fee
1125 - Fie
1126 - Foe
1128 + Third
1130Pandoc transforms this into a "compact list" (with no `<p>` tags around
1131"First", "Second", or "Third"), while markdown puts `<p>` tags around
1132"Second" and "Third" (but not "First"), because of the blank space
1133around "Third". Pandoc follows a simple rule: if the text is followed by
1134a blank line, it is treated as a paragraph. Since "Second" is followed
1135by a list, and not a blank line, it isn't treated as a paragraph. The
1136fact that the list is followed by a blank line is irrelevant. (Note:
1137Pandoc works this way even when the `--strict` option is specified. This
1138behavior is consistent with the official markdown syntax description,
1139even though it is different from that of `Markdown.pl`.)
1142### Ending a list ###
1144What if you want to put an indented code block after a list?
1146 - item one
1147 - item two
1149 { my code block }
1151Trouble! Here pandoc (like other markdown implementations) will treat
1152`{ my code block }` as the second paragraph of item two, and not as
1153a code block.
1155To "cut off" the list after item two, you can insert some non-indented
1156content, like an HTML comment, which won't produce visible output in
1157any format:
1159 - item one
1160 - item two
1162 <!-- end of list -->
1164 { my code block }
1166You can use the same trick if you want two consecutive lists instead
1167of one big list:
1169 1. one
1170 2. two
1171 3. three
1173 <!-- -->
1175 a. uno
1176 b. dos
1177 c. tres
1180Horizontal rules
1181----------------
1183A line containing a row of three or more `*`, `-`, or `_` characters
1184(optionally separated by spaces) produces a horizontal rule:
1186 * * * *
1188 ---------------
1191Tables
1192------
1194*Pandoc extension*.
1196Three kinds of tables may be used. All three kinds presuppose the use of
1197a fixed-width font, such as Courier.
1199**Simple tables** look like this:
1201 Right Left Center Default
1202 ------- ------ ---------- -------
1203 12 12 12 12
1204 123 123 123 123
1205 1 1 1 1
1207 Table: Demonstration of simple table syntax.
1209The headers and table rows must each fit on one line. Column
1210alignments are determined by the position of the header text relative
1211to the dashed line below it:[^4]
1213 - If the dashed line is flush with the header text on the right side
1214 but extends beyond it on the left, the column is right-aligned.
1215 - If the dashed line is flush with the header text on the left side
1216 but extends beyond it on the right, the column is left-aligned.
1217 - If the dashed line extends beyond the header text on both sides,
1218 the column is centered.
1219 - If the dashed line is flush with the header text on both sides,
1220 the default alignment is used (in most cases, this will be left).
1222[^4]: This scheme is due to Michel Fortin, who proposed it on the
1223 [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).
1225The table must end with a blank line, or a line of dashes followed by
1226a blank line. A caption may optionally be provided (as illustrated in
1227the example above). A caption is a paragraph beginning with the string
1228`Table:` (or just `:`), which will be stripped off. It may appear either
1229before or after the table.
1231The column headers may be omitted, provided a dashed line is used
1232to end the table. For example:
1234 ------- ------ ---------- -------
1235 12 12 12 12
1236 123 123 123 123
1237 1 1 1 1
1238 ------- ------ ---------- -------
1240When headers are omitted, column alignments are determined on the basis
1241of the first line of the table body. So, in the tables above, the columns
1242would be right, left, center, and right aligned, respectively.
1244**Multiline tables** allow headers and table rows to span multiple lines
1245of text (but cells that span multiple columns or rows of the table are
1246not supported). Here is an example:
1248 -------------------------------------------------------------
1249 Centered Default Right Left
1250 Header Aligned Aligned Aligned
1251 ----------- ------- --------------- -------------------------
1252 First row 12.0 Example of a row that
1253 spans multiple lines.
1255 Second row 5.0 Here's another one. Note
1256 the blank line between
1257 rows.
1258 -------------------------------------------------------------
1260 Table: Here's the caption. It, too, may span
1261 multiple lines.
1263These work like simple tables, but with the following differences:
1265 - They must begin with a row of dashes, before the header text
1266 (unless the headers are omitted).
1267 - They must end with a row of dashes, then a blank line.
1268 - The rows must be separated by blank lines.
1270In multiline tables, the table parser pays attention to the widths of
1271the columns, and the writers try to reproduce these relative widths in
1272the output. So, if you find that one of the columns is too narrow in the
1273output, try widening it in the markdown source.
1275Headers may be omitted in multiline tables as well as simple tables:
1277 ----------- ------- --------------- -------------------------
1278 First row 12.0 Example of a row that
1279 spans multiple lines.
1281 Second row 5.0 Here's another one. Note
1282 the blank line between
1283 rows.
1284 -------------------------------------------------------------
1286 : Here's a multiline table without headers.
1288It is possible for a multiline table to have just one row, but the row
1289should be followed by a blank line (and then the row of dashes that ends
1290the table), or the table may be interpreted as a simple table.
1292**Grid tables** look like this:
1294 : Sample grid table.
1296 +---------------+---------------+--------------------+
1297 | Fruit | Price | Advantages |
1298 +===============+===============+====================+
1299 | Bananas | $1.34 | - built-in wrapper |
1300 | | | - bright color |
1301 +---------------+---------------+--------------------+
1302 | Oranges | $2.10 | - cures scurvy |
1303 | | | - tasty |
1304 +---------------+---------------+--------------------+
1306The row of `=`s separates the header from the table body, and can be
1307omitted for a headerless table. The cells of grid tables may contain
1308arbitrary block elements (multiple paragraphs, code blocks, lists,
1309etc.). Alignments are not supported, nor are cells that span multiple
1310columns or rows. Grid tables can be created easily using [Emacs table mode].
1312 [Emacs table mode]: http://table.sourceforge.net/
1315Title block
1316-----------
1318*Pandoc extension*.
1320If the file begins with a title block
1322 % title
1323 % author(s) (separated by semicolons)
1324 % date
1326it will be parsed as bibliographic information, not regular text. (It
1327will be used, for example, in the title of standalone LaTeX or HTML
1328output.) The block may contain just a title, a title and an author,
1329or all three elements. If you want to include an author but no
1330title, or a title and a date but no author, you need a blank line:
1333 % Author
1335 % My title
1337 % June 15, 2006
1339The title may occupy multiple lines, but continuation lines must
1340begin with leading space, thus:
1342 % My title
1343 on multiple lines
1345If a document has multiple authors, the authors may be put on
1346separate lines with leading space, or separated by semicolons, or
1347both. So, all of the following are equivalent:
1349 % Author One
1350 Author Two
1352 % Author One; Author Two
1354 % Author One;
1355 Author Two
1357The date must fit on one line.
1359All three metadata fields may contain standard inline formatting
1360(italics, links, footnotes, etc.).
1362Title blocks will always be parsed, but they will affect the output only
1363when the `--standalone` (`-s`) option is chosen. In HTML output, titles
1364will appear twice: once in the document head -- this is the title that
1365will appear at the top of the window in a browser -- and once at the
1366beginning of the document body. The title in the document head can have
1367an optional prefix attached (`--title-prefix` or `-T` option). The title
1368in the body appears as an H1 element with class "title", so it can be
1369suppressed or reformatted with CSS. If a title prefix is specified with
1370`-T` and no title block appears in the document, the title prefix will
1371be used by itself as the HTML title.
1373The man page writer extracts a title, man page section number, and
1374other header and footer information from the title line. The title
1375is assumed to be the first word on the title line, which may optionally
1376end with a (single-digit) section number in parentheses. (There should
1377be no space between the title and the parentheses.) Anything after
1378this is assumed to be additional footer and header text. A single pipe
1379character (`|`) should be used to separate the footer text from the header
1380text. Thus,
1382 % PANDOC(1)
1384will yield a man page with the title `PANDOC` and section 1.
1386 % PANDOC(1) Pandoc User Manuals
1388will also have "Pandoc User Manuals" in the footer.
1390 % PANDOC(1) Pandoc User Manuals | Version 4.0
1392will also have "Version 4.0" in the header.
1395Backslash escapes
1396-----------------
1398Except inside a code block or inline code, any punctuation or space
1399character preceded by a backslash will be treated literally, even if it
1400would normally indicate formatting. Thus, for example, if one writes
1402 *\*hello\**
1404one will get
1406 <em>*hello*</em>
1408instead of
1410 <strong>hello</strong>
1412This rule is easier to remember than standard markdown's rule,
1413which allows only the following characters to be backslash-escaped:
1415 \`*_{}[]()>#+-.!
1417(However, if the `--strict` option is supplied, the standard
1418markdown rule will be used.)
1420A backslash-escaped space is parsed as a nonbreaking space. It will
1421appear in TeX output as `~` and in HTML and XML as `\&#160;` or
1422`\&nbsp;`.
1424A backslash-escaped newline (i.e. a backslash occurring at the end of
1425a line) is parsed as a hard line break. It will appear in TeX output as
1426`\\` and in HTML as `<br />`. This is a nice alternative to
1427markdown's "invisible" way of indicating hard line breaks using
1428two trailing spaces on a line.
1430Backslash escapes do not work in verbatim contexts.
1432Smart punctuation
1433-----------------
1435If the `--smart` option is specified, pandoc will produce typographically
1436correct output, converting straight quotes to curly quotes, `---` and `--`
1437to Em-dashes, and `...` to ellipses. Nonbreaking spaces are inserted after
1438certain abbreviations, such as "Mr."
1440Note: if your LaTeX template uses the `csquotes` package, pandoc will
1441detect automatically this and use `\enquote{...}` for quoted text.
1443Inline formatting
1444-----------------
1446### Emphasis ###
1448To *emphasize* some text, surround it with `*`s or `_`, like this:
1450 This text is _emphasized with underscores_, and this
1451 is *emphasized with asterisks*.
1453Double `*` or `_` produces **strong emphasis**:
1455 This is **strong emphasis** and __with underscores__.
1457A `*` or `_` character surrounded by spaces, or backslash-escaped,
1458will not trigger emphasis:
1460 This is * not emphasized *, and \*neither is this\*.
1462Because `_` is sometimes used inside words and identifiers,
1463pandoc does not interpret a `_` surrounded by alphanumeric
1464characters as an emphasis marker. If you want to emphasize
1465just part of a word, use `*`:
1467 feas*ible*, not feas*able*.
1470### Strikeout ###
1472*Pandoc extension*.
1474To strikeout a section of text with a horizontal line, begin and end it
1475with `~~`. Thus, for example,
1477 This ~~is deleted text.~~
1480### Superscripts and subscripts ###
1482*Pandoc extension*.
1484Superscripts may be written by surrounding the superscripted text by `^`
1485characters; subscripts may be written by surrounding the subscripted
1486text by `~` characters. Thus, for example,
1488 H~2~O is a liquid. 2^10^ is 1024.
1490If the superscripted or subscripted text contains spaces, these spaces
1491must be escaped with backslashes. (This is to prevent accidental
1492superscripting and subscripting through the ordinary use of `~` and `^`.)
1493Thus, if you want the letter P with 'a cat' in subscripts, use
1494`P~a\ cat~`, not `P~a cat~`.
1497### Verbatim ###
1499To make a short span of text verbatim, put it inside backticks:
1501 What is the difference between `>>=` and `>>`?
1503If the verbatim text includes a backtick, use double backticks:
1505 Here is a literal backtick `` ` ``.
1507(The spaces after the opening backticks and before the closing
1508backticks will be ignored.)
1510The general rule is that a verbatim span starts with a string
1511of consecutive backticks (optionally followed by a space)
1512and ends with a string of the same number of backticks (optionally
1513preceded by a space).
1515Note that backslash-escapes (and other markdown constructs) do not
1516work in verbatim contexts:
1518 This is a backslash followed by an asterisk: `\*`.
1521Math
1522----
1524*Pandoc extension*.
1526Anything between two `$` characters will be treated as TeX math. The
1527opening `$` must have a character immediately to its right, while the
1528closing `$` must have a character immediately to its left. Thus,
1529`$20,000 and $30,000` won't parse as math. If for some reason
1530you need to enclose text in literal `$` characters, backslash-escape
1531them and they won't be treated as math delimiters.
1533TeX math will be printed in all output formats. How it is rendered
1534depends on the output format:
1536Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt
1537 ~ It will appear verbatim between `$` characters.
1539reStructuredText
1540 ~ It will be rendered using an interpreted text role `:math:`, as described
1541 [here](http://www.american.edu/econ/itex2mml/mathhack.rst).
1543AsciiDoc
1544 ~ It will be rendered as `latexmath:[...]`.
1546Texinfo
1547 ~ It will be rendered inside a `@math` command.
1549groff man
1550 ~ It will be rendered verbatim without `$`'s.
1552MediaWiki
1553 ~ It will be rendered inside `<math>` tags.
1555Textile
1556 ~ It will be rendered inside `<span class="math">` tags.
1558RTF, DocBook, OpenDocument, ODT
1559 ~ It will be rendered, if possible, using unicode characters,
1560 and will otherwise appear verbatim.
1562HTML, Slidy, DZSlides, S5, EPUB
1563 ~ The way math is rendered in HTML will depend on the
1564 command-line options selected:
1566 1. The default is to render TeX math as far as possible using unicode
1567 characters, as with RTF, DocBook, and OpenDocument output. Formulas
1568 are put inside a `span` with `class="math"`, so that they may be
1569 styled differently from the surrounding text if needed.
1571 2. If the `--latexmathml` option is used, TeX math will be displayed
1572 between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
1573 The [LaTeXMathML] script will be used to render it as formulas.
1574 (This trick does not work in all browsers, but it works in Firefox.
1575 In browsers that do not support LaTeXMathML, TeX math will appear
1576 verbatim between $ characters.)
1578 3. If the `--jsmath` option is used, TeX math will be put inside
1579 `<span>` tags (for inline math) or `<div>` tags (for display math)
1580 with class `math`. The [jsMath] script will be used to render
1581 it.
1583 4. If the `--mimetex` option is used, the [mimeTeX] CGI script will
1584 be called to generate images for each TeX formula. This should
1585 work in all browsers. The `--mimetex` option takes an optional URL
1586 as argument. If no URL is specified, it will be assumed that the
1587 mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
1589 5. If the `--gladtex` option is used, TeX formulas will be enclosed
1590 in `<eq>` tags in the HTML output. The resulting `htex` file may then
1591 be processed by [gladTeX], which will produce image files for each
1592 formula and an `html` file with links to these images. So, the
1593 procedure is:
1595 pandoc -s --gladtex myfile.txt -o myfile.htex
1596 gladtex -d myfile-images myfile.htex
1597 # produces myfile.html and images in myfile-images
1599 6. If the `--webtex` option is used, TeX formulas will be converted
1600 to `<img>` tags that link to an external script that converts
1601 formulas to images. The formula will be URL-encoded and concatenated
1602 with the URL provided. If no URL is specified, the Google Chart
1603 API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).
1606Raw HTML
1607--------
1609Markdown allows you to insert raw HTML (or DocBook) anywhere in a document
1610(except verbatim contexts, where `<`, `>`, and `&` are interpreted
1611literally).
1613The raw HTML is passed through unchanged in HTML, S5, Slidy, DZSlides, EPUB,
1614Markdown, and Textile output, and suppressed in other formats.
1616*Pandoc extension*.
1618Standard markdown allows you to include HTML "blocks": blocks
1619of HTML between balanced tags that are separated from the surrounding text
1620with blank lines, and start and end at the left margin. Within
1621these blocks, everything is interpreted as HTML, not markdown;
1622so (for example), `*` does not signify emphasis.
1624Pandoc behaves this way when `--strict` is specified; but by default,
1625pandoc interprets material between HTML block tags as markdown.
1626Thus, for example, Pandoc will turn
1628 <table>
1629 <tr>
1630 <td>*one*</td>
1631 <td>[a link](http://google.com)</td>
1632 </tr>
1633 </table>
1635into
1637 <table>
1638 <tr>
1639 <td><em>one</em></td>
1640 <td><a href="http://google.com">a link</a></td>
1641 </tr>
1642 </table>
1644whereas `Markdown.pl` will preserve it as is.
1646There is one exception to this rule: text between `<script>` and
1647`<style>` tags is not interpreted as markdown.
1649This departure from standard markdown should make it easier to mix
1650markdown with HTML block elements. For example, one can surround
1651a block of markdown text with `<div>` tags without preventing it
1652from being interpreted as markdown.
1654Raw TeX
1655-------
1657*Pandoc extension*.
1659In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be
1660included in a document. Inline TeX commands will be preserved and passed
1661unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use
1662LaTeX to include BibTeX citations:
1664 This result was proved in \cite{jones.1967}.
1666Note that in LaTeX environments, like
1668 \begin{tabular}{|l|l|}\hline
1669 Age & Frequency \\ \hline
1670 18--25 & 15 \\
1671 26--35 & 33 \\
1672 36--45 & 22 \\ \hline
1673 \end{tabular}
1675the material between the begin and end tags will be interpreted as raw
1676LaTeX, not as markdown.
1678Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
1679and ConTeXt.
1681### Macros ###
1683For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and
1684`\renewcommand` definitions and apply the resulting macros to all LaTeX
1685math. So, for example, the following will work in all output formats,
1686not just LaTeX:
1688 \newcommand{\tuple}[1]{\langle #1 \rangle}
1690 $\tuple{a, b, c}$
1692In LaTeX output, the `\newcommand` definition will simply be passed
1693unchanged to the output.
1696Links
1697-----
1699Markdown allows links to be specified in several ways.
1701### Automatic links ###
1703If you enclose a URL or email address in pointy brackets, it
1704will become a link:
1706 <http://google.com>
1707 <sam@green.eggs.ham>
1710### Inline links ###
1712An inline link consists of the link text in square brackets,
1713followed by the URL in parentheses. (Optionally, the URL can
1714be followed by a link title, in quotes.)
1716 This is an [inline link](/url), and here's [one with
1717 a title](http://fsf.org "click here for a good time!").
1719There can be no space between the bracketed part and the parenthesized part.
1720The link text can contain formatting (such as emphasis), but the title cannot.
1723### Reference links ###
1725An *explicit* reference link has two parts, the link itself and the link
1726definition, which may occur elsewhere in the document (either
1727before or after the link).
1729The link consists of link text in square brackets, followed by a label in
1730square brackets. (There can be space between the two.) The link definition
1731must begin at the left margin or indented no more than three spaces. It
1732consists of the bracketed label, followed by a colon and a space, followed by
1733the URL, and optionally (after a space) a link title either in quotes or in
1734parentheses.
1736Here are some examples:
1738 [my label 1]: /foo/bar.html "My title, optional"
1739 [my label 2]: /foo
1740 [my label 3]: http://fsf.org (The free software foundation)
1741 [my label 4]: /bar#special 'A title in single quotes'
1743The URL may optionally be surrounded by angle brackets:
1745 [my label 5]: <http://foo.bar.baz>
1747The title may go on the next line:
1749 [my label 3]: http://fsf.org
1750 "The free software foundation"
1752Note that link labels are not case sensitive. So, this will work:
1754 Here is [my link][FOO]
1756 [Foo]: /bar/baz
1758In an *implicit* reference link, the second pair of brackets is
1759empty, or omitted entirely:
1761 See [my website][], or [my website].
1763 [my website]: http://foo.bar.baz
1766Images
1767------
1769A link immediately preceded by a `!` will be treated as an image.
1770The link text will be used as the image's alt text:
1772 ![la lune](lalune.jpg "Voyage to the moon")
1774 ![movie reel]
1776 [movie reel]: movie.gif
1778### Pictures with captions ###
1780*Pandoc extension*.
1782An image occurring by itself in a paragraph will be rendered as
1783a figure with a caption.[^5] (In LaTeX, a figure environment will be
1784used; in HTML, the image will be placed in a `div` with class
1785`figure`, together with a caption in a `p` with class `caption`.)
1786The image's alt text will be used as the caption.
1788 ![This is the caption](/url/of/image.png)
1790[^5]: This feature is not yet implemented for RTF, OpenDocument, or
1791 ODT. In those formats, you'll just get an image in a paragraph by
1792 itself, with no caption.
1794If you just want a regular inline image, just make sure it is not
1795the only thing in the paragraph. One way to do this is to insert a
1796nonbreaking space after the image:
1798 ![This image won't be a figure](/url/of/image.png)\
1801Footnotes
1802---------
1804*Pandoc extension*.
1806Pandoc's markdown allows footnotes, using the following syntax:
1808 Here is a footnote reference,[^1] and another.[^longnote]
1810 [^1]: Here is the footnote.
1812 [^longnote]: Here's one with multiple blocks.
1814 Subsequent paragraphs are indented to show that they
1815 belong to the previous footnote.
1817 { some.code }
1819 The whole paragraph can be indented, or just the first
1820 line. In this way, multi-paragraph footnotes work like
1821 multi-paragraph list items.
1823 This paragraph won't be part of the note, because it
1824 isn't indented.
1826The identifiers in footnote references may not contain spaces, tabs,
1827or newlines. These identifiers are used only to correlate the
1828footnote reference with the note itself; in the output, footnotes
1829will be numbered sequentially.
1831The footnotes themselves need not be placed at the end of the
1832document. They may appear anywhere except inside other block elements
1833(lists, block quotes, tables, etc.).
1835Inline footnotes are also allowed (though, unlike regular notes,
1836they cannot contain multiple paragraphs). The syntax is as follows:
1838 Here is an inline note.^[Inlines notes are easier to write, since
1839 you don't have to pick an identifier and move down to type the
1840 note.]
1842Inline and regular footnotes may be mixed freely.
1845Citations
1846---------
1848*Pandoc extension*.
1850Pandoc can automatically generate citations and a bibliography in a number of
1851styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature,
1852you will need a bibliographic database in one of the following formats:
1854 Format File extension
1855 ------------ --------------
1856 MODS .mods
1857 BibTeX/BibLaTeX .bib
1858 RIS .ris
1859 EndNote .enl
1860 EndNote XML .xml
1861 ISI .wos
1862 MEDLINE .medline
1863 Copac .copac
1864 JSON citeproc .json
1866You will need to specify the bibliography file using the `--bibliography`
1867command-line option (which may be repeated if you have several
1868bibliographies).
1870By default, pandoc will use a Chicago author-date format for citations
1871and references. To use another style, you will need to use the
1872`--csl` option to specify a [CSL] 1.0 style file. A primer on
1873creating and modifying CSL styles can be found at
1874<http://citationstyles.org/downloads/primer.html>.
1875A repository of CSL styles can be found at
1876<https://github.com/citation-style-language/styles>.
1877See also <http://zotero.org/styles> for easy browsing.
1879Citations go inside square brackets and are separated by semicolons.
1880Each citation must have a key, composed of '@' + the citation
1881identifier from the database, and may optionally have a prefix,
1882a locator, and a suffix. Here are some examples:
1884 Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].
1886 Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].
1888 Blah blah [@smith04; @doe99].
1890A minus sign (`-`) before the `@` will suppress mention of
1891the author in the citation. This can be useful when the
1892author is already mentioned in the text:
1894 Smith says blah [-@smith04].
1896You can also write an in-text citation, as follows:
1898 @smith04 says blah.
1900 @smith04 [p. 33] says blah.
1902If the style calls for a list of works cited, it will be placed
1903at the end of the document. Normally, you will want to end your
1904document with an appropriate header:
1906 last paragraph...
1908 # References
1910The bibliography will be inserted after this header.
1913Producing slide shows with Pandoc
1914=================================
1916You can use Pandoc to produce an HTML + javascript slide presentation
1917that can be viewed via a web browser. There are three ways to do this,
1918using [S5], [DZSlides], or [Slidy]. You can also produce a PDF slide
1919show using [LaTeX beamer]: just pass the `--beamer` option to
1920`markdown2pdf`.
1922Here's the markdown source for a simple slide show, `eating.txt`:
1924 % Eating Habits
1925 % John Doe
1926 % March 22, 2005
1928 # In the morning
1930 - Eat eggs
1931 - Drink coffee
1933 # In the evening
1935 - Eat spaghetti
1936 - Drink wine
1938 --------------------------
1940 ![picture of spaghetti](images/spaghetti.jpg)
1942To produce the slide show, simply type
1944 pandoc -w s5 -s eating.txt > eating.html
1946for S5, or
1948 pandoc -w slidy -s eating.txt > eating.html
1950for Slidy, or
1952 pandoc -w dzslides -s eating.txt > eating.html
1954for DZSlides.
1956A title page is constructed automatically from the document's title
1957block. Each level-one header and horizontal rule begins a new slide.
1958(If beamer is used, all headers begin a new slide.)
1960For Slidy and S5, the file produced by pandoc with the `-s/--standalone`
1961option embeds a link to javascripts and CSS files, which are assumed to
1962be available at the relative path `s5/default` (for S5) or at the Slidy
1963website at `w3.org` (for Slidy). (These paths can be changed by setting
1964the `slidy-url` or `s5-url` variables; see `--variable`, above.) For DZSlides,
1965the (relatively short) javascript and css are included in the file by default.
1967You can change the style of the slides by putting customized CSS files
1968in `$DATADIR/s5/default` (for S5) or `$DATADIR/slidy` (for Slidy),
1969where `$DATADIR` is the user data directory (see `--data-dir`, above).
1970The originals may be found in pandoc's system data directory (generally
1971`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any
1972files it does not find in the user data directory.
1974The `--self-contained` option can be used to produce a single file that
1975contains all of the data necessary to display the slide show, including
1976linked scripts, stylesheets, images, and videos.
1978Incremental lists
1979-----------------
1981By default, these writers produces lists that display "all at once."
1982If you want your lists to display incrementally (one item at a time),
1983use the `-i` option. If you want a particular list to depart from the
1984default (that is, to display incrementally without the `-i` option and
1985all at once with the `-i` option), put it in a block quote:
1987 > - Eat spaghetti
1988 > - Drink wine
1990In this way incremental and nonincremental lists can be mixed in
1991a single document.
1993Literate Haskell support
1994========================
1996If you append `+lhs` to an appropriate input or output format (`markdown`,
1997`rst`, or `latex` for input or output; `html` or `html5` for output only),
1998pandoc will treat the document as literate Haskell source. This means that
2000 - In markdown input, "bird track" sections will be parsed as Haskell
2001 code rather than block quotations. Text between `\begin{code}`
2002 and `\end{code}` will also be treated as Haskell code.
2004 - In markdown output, code blocks with class `haskell` will be
2005 rendered using bird tracks, and block quotations will be
2006 indented one space, so they will not be treated as Haskell code.
2007 In addition, headers will be rendered setext-style (with underlines)
2008 rather than atx-style (with '#' characters). (This is because ghc
2009 treats '#' characters in column 1 as introducing line numbers.)
2011 - In restructured text input, "bird track" sections will be parsed
2012 as Haskell code.
2014 - In restructured text output, code blocks with class `haskell` will
2015 be rendered using bird tracks.
2017 - In LaTeX input, text in `code` environments will be parsed as
2018 Haskell code.
2020 - In LaTeX output, code blocks with class `haskell` will be rendered
2021 inside `code` environments.
2023 - In HTML output, code blocks with class `haskell` will be rendered
2024 with class `literatehaskell` and bird tracks.
2026Examples:
2028 pandoc -f markdown+lhs -t html
2030reads literate Haskell source formatted with markdown conventions and writes
2031ordinary HTML (without bird tracks).
2033 pandoc -f markdown+lhs -t html+lhs
2035writes HTML with the Haskell code in bird tracks, so it can be copied
2036and pasted as literate Haskell source.
2038Authors
2039=======
2041© 2006-2011 John MacFarlane (jgm at berkeley dot edu). Released under the
2042[GPL], version 2 or greater. This software carries no warranty of
2043any kind. (See COPYRIGHT for full copyright and warranty notices.)
2044Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,
2045Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,
2046Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton,
2047Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner, qerub,
2048Christopher Sawicki, Kelsey Hightower.
2050[markdown]: http://daringfireball.net/projects/markdown/
2051[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
2052[S5]: http://meyerweb.com/eric/tools/s5/
2053[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
2054[HTML]: http://www.w3.org/TR/html40/
2055[XHTML]: http://www.w3.org/TR/xhtml1/
2056[LaTeX]: http://www.latex-project.org/
2057[LaTeX beamer]: http://www.tex.ac.uk/CTAN/macros/latex/contrib/beamer
2058[ConTeXt]: http://www.pragma-ade.nl/
2059[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
2060[DocBook XML]: http://www.docbook.org/
2061[OpenDocument XML]: http://opendocument.xml.org/
2062[ODT]: http://en.wikipedia.org/wiki/OpenDocument
2063[Textile]: http://redcloth.org/textile
2064[MediaWiki markup]: http://www.mediawiki.org/wiki/Help:Formatting
2065[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html
2066[Haskell]: http://www.haskell.org/
2067[GNU Texinfo]: http://www.gnu.org/software/texinfo/
2068[Emacs Org-Mode]: http://orgmode.org
2069[AsciiDoc]: http://www.methods.co.nz/asciidoc/
2070[EPUB]: http://www.idpf.org/
2071[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
2072[DZSlides]: http://paulrouget.com/dzslides/