git.iko.soy/typeable/pandoc
on 1.8.1.2 help sign in
1997 lines 69 kB history raw
1% Pandoc User's Guide
2% John MacFarlane
3% January 29, 2011
5Synopsis
6========
8pandoc [*options*] [*input-file*]...
10Description
11===========
13Pandoc is a [Haskell] library for converting from one markup format to
14another, and a command-line tool that uses this library. It can read
15[markdown] and (subsets of) [Textile], [reStructuredText], [HTML],
16and [LaTeX]; and it can write plain text, [markdown], [reStructuredText],
17[HTML], [LaTeX], [ConTeXt], [RTF], [DocBook XML], [OpenDocument XML], [ODT],
18[GNU Texinfo], [MediaWiki markup], [EPUB], [Textile], [groff man] pages,
19[Emacs Org-Mode], and [Slidy] or [S5] HTML slide shows.
21Pandoc's enhanced version of markdown includes syntax for footnotes,
22tables, flexible ordered lists, definition lists, delimited code blocks,
23superscript, subscript, strikeout, title blocks, automatic tables of
24contents, embedded LaTeX math, citations, and markdown inside HTML block
25elements. (These enhancements, described below under
26[Pandoc's markdown](#pandocs-markdown), can be disabled using the `--strict`
27option.)
29In contrast to most existing tools for converting markdown to HTML, which
30use regex substitutions, Pandoc has a modular design: it consists of a
31set of readers, which parse text in a given format and produce a native
32representation of the document, and a set of writers, which convert
33this native representation into a target format. Thus, adding an input
34or output format requires only adding a reader or writer.
36Using Pandoc
37------------
39If no *input-file* is specified, input is read from *stdin*.
40Otherwise, the *input-files* are concatenated (with a blank
41line between each) and used as input. Output goes to *stdout* by
42default (though output to *stdout* is disabled for the `odt` and
43`epub` output formats). For output to a file, use the `-o` option:
45 pandoc -o output.html input.txt
47Instead of a file, an absolute URI may be given. In this case
48pandoc will fetch the content using HTTP:
50 pandoc -f html -t markdown http://www.fsf.org
52If multiple input files are given, `pandoc` will concatenate them all (with
53blank lines between them) before parsing.
55The format of the input and output can be specified explicitly using
56command-line options. The input format can be specified using the
57`-r/--read` or `-f/--from` options, the output format using the
58`-w/--write` or `-t/--to` options. Thus, to convert `hello.txt` from
59markdown to LaTeX, you could type:
61 pandoc -f markdown -t latex hello.txt
63To convert `hello.html` from html to markdown:
65 pandoc -f html -t markdown hello.html
67Supported output formats are listed below under the `-t/--to` option.
68Supported input formats are listed below under the `-f/--from` option. Note
69that the `rst`, `textile`, `latex`, and `html` readers are not complete;
70there are some constructs that they do not parse.
72If the input or output format is not specified explicitly, `pandoc`
73will attempt to guess it from the extensions of
74the input and output filenames. Thus, for example,
76 pandoc -o hello.tex hello.txt
78will convert `hello.txt` from markdown to LaTeX. If no output file
79is specified (so that output goes to *stdout*), or if the output file's
80extension is unknown, the output format will default to HTML.
81If no input file is specified (so that input comes from *stdin*), or
82if the input files' extensions are unknown, the input format will
83be assumed to be markdown unless explicitly specified.
85Pandoc uses the UTF-8 character encoding for both input and output.
86If your local character encoding is not UTF-8, you
87should pipe input and output through `iconv`:
89 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
91Wrappers
92========
94`markdown2pdf`
95--------------
97The standard Pandoc installation includes `markdown2pdf`, a wrapper
98around `pandoc` and `pdflatex` that produces PDFs directly from markdown
99sources. The default behavior of `markdown2pdf` is to create a file with
100the same base name as the first argument and the extension `pdf`; thus,
101for example,
103 markdown2pdf sample.txt endnotes.txt
105will produce `sample.pdf`. (If `sample.pdf` exists already,
106it will be backed up before being overwritten.) An output file
107name can be specified explicitly using the `-o` option:
109 markdown2pdf -o book.pdf chap1 chap2
111If no input file is specified, input will be taken from *stdin*.
112All of `pandoc`'s options will work with `markdown2pdf` as well.
114`markdown2pdf` assumes that `pdflatex` is in the path. It also
115assumes that the following LaTeX packages are available:
116`unicode`, `fancyhdr` (if you have verbatim text in footnotes),
117`graphicx` (if you use images), `array` (if you use tables),
118and `ulem` (if you use strikeout text). If they are not already
119included in your LaTeX distribution, you can get them from
120[CTAN]. A full [TeX Live] or [MacTeX] distribution will have all of
121these packages.
123`hsmarkdown`
124------------
126A user who wants a drop-in replacement for `Markdown.pl` may create
127a symbolic link to the `pandoc` executable called `hsmarkdown`. When
128invoked under the name `hsmarkdown`, `pandoc` will behave as if the
129`--strict` flag had been selected, and no command-line options will be
130recognized. However, this approach does not work under Cygwin, due to
131problems with its simulation of symbolic links.
133[Cygwin]: http://www.cygwin.com/
134[`iconv`]: http://www.gnu.org/software/libiconv/
135[CTAN]: http://www.ctan.org "Comprehensive TeX Archive Network"
136[TeX Live]: http://www.tug.org/texlive/
137[MacTeX]: http://www.tug.org/mactex/
139Options
140=======
142`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*
143: Specify input format. *FORMAT* can be `native` (native Haskell),
144 `json` (JSON version of native AST), `markdown` (markdown),
145 `textile` (Textile), `rst` (reStructuredText), `html` (HTML),
146 or `latex` (LaTeX). If `+lhs` is appended to `markdown`, `rst`,
147 or `latex`, the input will be treated as literate Haskell source:
148 see [Literate Haskell support](#literate-haskell-support),
149 below.
151`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
152: Specify output format. *FORMAT* can be `native` (native Haskell),
153 `json` (JSON version of native AST), `plain` (plain text),
154 `markdown` (markdown), `rst` (reStructuredText),
155 `html` (HTML), `latex` (LaTeX), `context` (ConTeXt), `man` (groff man),
156 `mediawiki` (MediaWiki markup), `textile` (Textile), `org` (Emacs
157 Org-Mode), `texinfo` (GNU Texinfo), `docbook` (DocBook XML),
158 `opendocument` (OpenDocument XML), `odt` (OpenOffice text document),
159 `epub` (EPUB book), `slidy` (Slidy HTML and javascript slide show),
160 `s5` (S5 HTML and javascript slide show), or `rtf` (rich text
161 format). Note that `odt` and `epub` output will not be directed to
162 *stdout*; an output filename must be specified using the `-o/--output`
163 option. If `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`,
164 the output will be rendered as literate Haskell source:
165 see [Literate Haskell support](#literate-haskell-support),
166 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 and S5 output; raw LaTeX can be printed in markdown, reStructuredText,
202 LaTeX, and ConTeXt output. The default is for the readers to omit
203 untranslatable HTML codes and LaTeX environments. (The LaTeX reader
204 does pass through untranslatable LaTeX *commands*, even if `-R` is not
205 specified.)
207`-S`, `--smart`
208: Produce typographically correct output, converting straight quotes
209 to curly quotes, `---` and `--` to dashes, ande `...` 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`.
219`-m` [*URL*], `--latexmathml`[=*URL*]
220: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.
221 To insert a link to a local copy of the `LaTeXMathML.js` script,
222 provide a *URL*. If no *URL* is provided, the contents of the
223 script will be inserted directly into the HTML header, preserving
224 portability at the price of efficiency. If you plan to use math on
225 several pages, it is much better to link to a copy of the script,
226 so it can be cached.
228`--mathml`[=*URL*]
229: Convert TeX math to MathML. In standalone mode, a small javascript
230 (or a link to such a script if a *URL* is supplied) will be inserted that
231 allows the MathML to be viewed on some browsers.
233`--jsmath`[=*URL*]
234: Use [jsMath] to display embedded TeX math in HTML output.
235 The *URL* should point to the jsMath load script (e.g.
236 `jsMath/easy/load.js`); if provided, it will be linked to in
237 the header of standalone HTML documents. If a *URL* is not provided,
238 no link to the jsMath load script will be inserted; it is then
239 up to the author to provide such a link in the HTML template.
241`--mathjax=`*URL*
242: Use [MathJax] to display embedded TeX math in HTML output.
243 The *URL* should point to the `MathJax.js` load script.
245`--gladtex`
246: Enclose TeX math in `<eq>` tags in HTML output. These can then
247 be processed by [gladTeX] to produce links to images of the typeset
248 formulas.
250`--mimetex`[=*URL*]
251: Render TeX math using the [mimeTeX] CGI script. If *URL* is not
252 specified, it is assumed that the script is at `/cgi-bin/mimetex.cgi`.
254`--webtex`[=*URL*]
255: Render TeX formulas using an external script that converts TeX
256 formulas to images. The formula will be concatenated with the URL
257 provided. If *URL* is not specified, the Google Chart API will be used.
259`-i`, `--incremental`
260: Make list items in Slidy or S5 display incrementally (one by one).
261 The default is for lists to be displayed all at once.
263`--offline`
264: Include all the CSS and javascript needed for a Slidy or S5 slide
265 show in the output, so that the slide show will work even when no
266 internet connection is available.
268`--xetex`
269: Create LaTeX outut suitable for processing by XeTeX.
271`--chapters`
272: Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook
273 output.
275`-N`, `--number-sections`
276: Number section headings in LaTeX, ConTeXt, or HTML output.
277 By default, sections are not numbered.
279`--listings`
280: Use listings package for LaTeX code blocks
282`--section-divs`
283: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),
284 and attach identifiers to the enclosing `<div>` (or `<section>`)
285 rather than the header itself.
286 See [Section identifiers](#header-identifiers-in-html), below.
288`--no-wrap`
289: Disable text wrapping in output. By default, text is wrapped
290 appropriately for the output format.
292`--columns`=*NUMBER*
293: Specify length of lines in characters (for text wrapping).
295`--ascii`
296: Use only ascii characters in output. Currently supported only
297 for HTML output (which uses numerical entities instead of
298 UTF-8 when this option is selected).
300`--email-obfuscation=`*none|javascript|references*
301: Specify a method for obfuscating `mailto:` links in HTML documents.
302 *none* leaves `mailto:` links as they are. *javascript* obfuscates
303 them using javascript. *references* obfuscates them by printing their
304 letters as decimal or hexadecimal character references.
305 If `--strict` is specified, *references* is used regardless of the
306 presence of this option.
308`--id-prefix`=*STRING*
309: Specify a prefix to be added to all automatically generated identifiers
310 in HTML output. This is useful for preventing duplicate identifiers
311 when generating fragments to be included in other pages.
313`--indented-code-classes=`*CLASSES*
314: Specify classes to use for indented code blocks--for example,
315 `perl,numberLines` or `haskell`. Multiple classes may be separated
316 by spaces or commas.
318`--toc`, `--table-of-contents`
319: Include an automatically generated table of contents (or, in
320 the case of `latex`, `context`, and `rst`, an instruction to create
321 one) in the output document. This option has no effect on `man`,
322 `docbook`, `slidy`, or `s5` output.
324`--base-header-level=`*NUMBER*
325: Specify the base level for headers (defaults to 1).
327`--template=`*FILE*
328: Use *FILE* as a custom template for the generated document. Implies
329 `--standalone`. See [Templates](#templates) below for a description
330 of template syntax. If this option is not used, a default
331 template appropriate for the output format will be used. See also
332 `-D/--print-default-template`.
334`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
335: Set the template variable *KEY* to the value *VAL* when rendering the
336 document in standalone mode. This is only useful when the
337 `--template` option is used to specify a custom template, since
338 pandoc automatically sets the variables used in the default
339 templates.
341`-c` *URL*, `--css=`*URL*
342: Link to a CSS style sheet.
344`-H` *FILE*, `--include-in-header=`*FILE*
345: Include contents of *FILE*, verbatim, at the end of the header.
346 This can be used, for example, to include special
347 CSS or javascript in HTML documents. This option can be used
348 repeatedly to include multiple files in the header. They will be
349 included in the order specified. Implies `--standalone`.
351`-B` *FILE*, `--include-before-body=`*FILE*
352: Include contents of *FILE*, verbatim, at the beginning of the
353 document body (e.g. after the `<body>` tag in HTML, or the
354 `\begin{document}` command in LaTeX). This can be used to include
355 navigation bars or banners in HTML documents. This option can be
356 used repeatedly to include multiple files. They will be included in
357 the order specified. Implies `--standalone`.
359`-A` *FILE*, `--include-after-body=`*FILE*
360: Include contents of *FILE*, verbatim, at the end of the document
361 body (before the `</body>` tag in HTML, or the
362 `\end{document}` command in LaTeX). This option can be be used
363 repeatedly to include multiple files. They will be included in the
364 order specified. Implies `--standalone`.
366`--reference-odt=`*FILE*
367: Use the specified file as a style reference in producing an ODT.
368 For best results, the reference ODT should be a modified version
369 of an ODT produced using pandoc. The contents of the reference ODT
370 are ignored, but its stylesheets are used in the new ODT. If no
371 reference ODT is specified on the command line, pandoc will look
372 for a file `reference.odt` in the user data directory (see
373 `--data-dir`). If this is not found either, sensible defaults will be
374 used.
376`--epub-stylesheet=`*FILE*
377: Use the specified CSS file to style the EPUB. If no stylesheet
378 is specified, pandoc will look for a file `epub.css` in the
379 user data directory (see `--data-dir`, below). If it is not
380 found there, sensible defaults will be used.
382`--epub-cover-image=`*FILE*
383: Use the specified image as the EPUB cover. It is recommended
384 that the image be less than 1000px in width and height.
386`--epub-metadata=`*FILE*
387: Look in the specified XML file for metadata for the EPUB.
388 The file should contain a series of Dublin Core elements,
389 as documented at <http://dublincore.org/documents/dces/>.
390 For example:
392 <dc:rights>Creative Commons</dc:rights>
393 <dc:language>es-AR</dc:language>
395 By default, pandoc will include the following metadata elements:
396 `<dc:title>` (from the document title), `<dc:creator>` (from the
397 document authors), `<dc:language>` (from the locale), and
398 `<dc:identifier id="BookId">` (a randomly generated UUID). Any of
399 these may be overridden by elements in the metadata file.
401`-D` *FORMAT*, `--print-default-template=`*FORMAT*
402: Print the default template for an output *FORMAT*. (See `-t`
403 for a list of possible *FORMAT*s.)
405`-T` *STRING*, `--title-prefix=`*STRING*
406: Specify *STRING* as a prefix at the beginning of the title
407 that appears in the HTML header (but not in the title as it
408 appears at the beginning of the HTML body). Implies
409 `--standalone`.
411`--bibliography=`*FILE*
412: Specify bibliography database to be used in resolving
413 citations. The database type will be determined from the
414 extension of *FILE*, which may be `.mods` (MODS format),
415 `.bib` (BibTeX format), `.bbx` (BibLaTeX format),
416 `.ris` (RIS format), `.enl` (EndNote format),
417 `.xml` (EndNote XML format), `.wos` (ISI format),
418 `.medline` (MEDLINE format), `.copac` (Copac format),
419 or `.json` (citeproc JSON). If you want to use multiple
420 bibliographies, just use this option repeatedly.
422`--csl=`*FILE*
423: Specify [CSL] style to be used in formatting citations and
424 the bibliography. If *FILE* is not found, pandoc will look
425 for it in
427 $HOME/.csl
429 in unix and
431 C:\Documents And Settings\USERNAME\Application Data\csl
433 in Windows. If the `--csl` option is not specified, pandoc
434 will use a default style: either `default.csl` in the
435 user data directory (see `--data-dir`), or, if that is
436 not present, the Chicago author-date style.
438`--natbib`
439: Use natbib for citations in LaTeX output.
441`--biblatex`
442: Use biblatex for citations in LaTeX output.
444`--data-dir=`*DIRECTORY*
445: Specify the user data directory to search for pandoc data files.
446 If this option is not specified, the default user data directory
447 will be used:
449 $HOME/.pandoc
451 in unix and
453 C:\Documents And Settings\USERNAME\Application Data\pandoc
455 in Windows. A `reference.odt`, `epub.css`, `templates` directory,
456 or `s5` directory placed in this directory will override pandoc's
457 normal defaults.
459`--dump-args`
460: Print information about command-line arguments to *stdout*, then exit.
461 This option is intended primarily for use in wrapper scripts.
462 The first line of output contains the name of the output file specified
463 with the `-o` option, or `-` (for *stdout*) if no output file was
464 specified. The remaining lines contain the command-line arguments,
465 one per line, in the order they appear. These do not include regular
466 Pandoc options and their arguments, but do include any options appearing
467 after a `--` separator at the end of the line.
469`--ignore-args`
470: Ignore command-line arguments (for use in wrapper scripts).
471 Regular Pandoc options are not ignored. Thus, for example,
473 pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
475 is equivalent to
477 pandoc -o foo.html -s
479`-v`, `--version`
480: Print version.
482`-h`, `--help`
483: Show usage message.
485[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/
486[jsMath]: http://www.math.union.edu/~dpvc/jsmath/
487[MathJax]: http://www.mathjax.org/
488[gladTeX]: http://www.math.uio.no/~martingu/gladtex/index.html
489[mimeTeX]: http://www.forkosh.com/mimetex.html
490[CSL]: http://CitationStyles.org
492Templates
493=========
495When the `-s/--standalone` option is used, pandoc uses a template to
496add header and footer material that is needed for a self-standing
497document. To see the default template that is used, just type
499 pandoc -D FORMAT
501where `FORMAT` is the name of the output format. A custom template
502can be specified using the `--template` option. You can also override
503the system default templates for a given output format `FORMAT`
504by putting a file `templates/FORMAT.template` in the user data
505directory (see `--data-dir`, above).
507Templates may contain *variables*. Variable names are sequences of
508alphanumerics, `-`, and `_`, starting with a letter. A variable name
509surrounded by `$` signs will be replaced by its value. For example,
510the string `$title$` in
512 <title>$title$</title>
514will be replaced by the document title.
516To write a literal `$` in a template, use `$$`.
518Some variables are set automatically by pandoc. These vary somewhat
519depending on the output format, but include:
521`header-includes`
522: contents specified by `-H/--include-in-header` (may have multiple
523 values)
524`toc`
525: non-null value if `--toc/--table-of-contents` was specified
526`include-before`
527: contents specified by `-B/--include-before-body` (may have
528 multiple values)
529`include-after`
530: contents specified by `-A/--include-after-body` (may have
531 multiple values)
532`body`
533: body of document
534`title`
535: title of document, as specified in title block
536`author`
537: author of document, as specified in title block (may have
538 multiple values)
539`date`
540: date of document, as specified in title block
541`lang`
542: language code for HTML documents
544Variables may be set at the command line using the `-V/--variable`
545option. This allows users to include custom variables in their
546templates.
548Templates may contain conditionals. The syntax is as follows:
550 $if(variable)$
551 X
552 $else$
553 Y
554 $endif$
556This will include `X` in the template if `variable` has a non-null
557value; otherwise it will include `Y`. `X` and `Y` are placeholders for
558any valid template text, and may include interpolated variables or other
559conditionals. The `$else$` section may be omitted.
561When variables can have multiple values (for example, `author` in
562a multi-author document), you can use the `$for$` keyword:
564 $for(author)$
565 <meta name="author" content="$author$" />
566 $endfor$
568You can optionally specify a separator to be used between
569consecutive items:
571 $for(author)$$author$$sep$, $endfor$
573Pandoc's markdown
574=================
576Pandoc understands an extended and slightly revised version of
577John Gruber's [markdown] syntax. This document explains the syntax,
578noting differences from standard markdown. Except where noted, these
579differences can be suppressed by specifying the `--strict` command-line
580option.
582Philosophy
583----------
585Markdown is designed to be easy to write, and, even more importantly,
586easy to read:
588> A Markdown-formatted document should be publishable as-is, as plain
589> text, without looking like it's been marked up with tags or formatting
590> instructions.
591> -- [John Gruber](http://daringfireball.net/projects/markdown/syntax#philosophy)
593This principle has guided pandoc's decisions in finding syntax for
594tables, footnotes, and other extensions.
596There is, however, one respect in which pandoc's aims are different
597from the original aims of markdown. Whereas markdown was originally
598designed with HTML generation in mind, pandoc is designed for multiple
599output formats. Thus, while pandoc allows the embedding of raw HTML,
600it discourages it, and provides other, non-HTMLish ways of representing
601important document elements like definition lists, tables, mathematics, and
602footnotes.
604Paragraphs
605----------
607A paragraph is one or more lines of text followed by one or more blank line.
608Newlines are treated as spaces, so you can reflow your paragraphs as you like.
609If you need a hard line break, put two or more spaces at the end of a line,
610or or type a backslash followed by a newline.
612Headers
613-------
615There are two kinds of headers, Setext and atx.
617### Setext-style headers ###
619A setext-style header is a line of text "underlined" with a row of `=` signs
620(for a level one header) of `-` signs (for a level two header):
622 A level-one header
623 ==================
625 A level-two header
626 ------------------
628The header text can contain inline formatting, such as emphasis (see
629[Inline formatting](#inline-formatting), below).
632### Atx-style headers ###
634An Atx-style header consists of one to six `#` signs and a line of
635text, optionally followed by any number of `#` signs. The number of
636`#` signs at the beginning of the line is the header level:
638 ## A level-two header
640 ### A level-three header ###
642As with setext-style headers, the header text can contain formatting:
644 # A level-one header with a [link](/url) and *emphasis*
646Standard markdown syntax does not require a blank line before a header.
647Pandoc does require this (except, of course, at the beginning of the
648document). The reason for the requirement is that it is all too easy for a
649`#` to end up at the beginning of a line by accident (perhaps through line
650wrapping). Consider, for example:
652 I like several of their flavors of ice cream:
653 #22, for example, and #5.
656### Header identifiers in HTML ###
658*Pandoc extension*.
660Each header element in pandoc's HTML output is given a unique
661identifier. This identifier is based on the text of the header. To
662derive the identifier from the header text,
664 - Remove all formatting, links, etc.
665 - Remove all punctuation, except underscores, hyphens, and periods.
666 - Replace all spaces and newlines with hyphens.
667 - Convert all alphabetic characters to lowercase.
668 - Remove everything up to the first letter (identifiers may
669 not begin with a number or punctuation mark).
670 - If nothing is left after this, use the identifier `section`.
672Thus, for example,
674 Header Identifier
675 ------------------------------- ----------------------------
676 Header identifiers in HTML `header-identifiers-in-html`
677 *Dogs*?--in *my* house? `dogs--in-my-house`
678 [HTML], [S5], or [RTF]? `html-s5-or-rtf`
679 3. Applications `applications`
680 33 `section`
682These rules should, in most cases, allow one to determine the identifier
683from the header text. The exception is when several headers have the
684same text; in this case, the first will get an identifier as described
685above; the second will get the same identifier with `-1` appended; the
686third with `-2`; and so on.
688These identifiers are used to provide link targets in the table of
689contents generated by the `--toc|--table-of-contents` option. They
690also make it easy to provide links from one section of a document to
691another. A link to this section, for example, might look like this:
693 See the section on
694 [header identifiers](#header-identifiers-in-html).
696Note, however, that this method of providing links to sections works
697only in HTML.
699If the `--section-divs` option is specified, then each section will
700be wrapped in a `div` (or a `section`, if `--html5` was specified),
701and the identifier will be attached to the enclosing `<div>`
702(or `<section>`) tag rather than the header itself. This allows entire
703sections to be manipulated using javascript or treated differently in
704CSS.
707Block quotations
708----------------
710Markdown uses email conventions for quoting blocks of text.
711A block quotation is one or more paragraphs or other block elements
712(such as lists or headers), with each line preceded by a `>` character
713and a space. (The `>` need not start at the left margin, but it should
714not be indented more than three spaces.)
716 > This is a block quote. This
717 > paragraph has two lines.
718 >
719 > 1. This is a list inside a block quote.
720 > 2. Second item.
722A "lazy" form, which requires the `>` character only on the first
723line of each block, is also allowed:
725 > This is a block quote. This
726 paragraph has two lines.
728 > 1. This is a list inside a block quote.
729 2. Second item.
731Among the block elements that can be contained in a block quote are
732other block quotes. That is, block quotes can be nested:
734 > This is a block quote.
735 >
736 > > A block quote within a block quote.
738Standard markdown syntax does not require a blank line before a block
739quote. Pandoc does require this (except, of course, at the beginning of the
740document). The reason for the requirement is that it is all too easy for a
741`>` to end up at the beginning of a line by accident (perhaps through line
742wrapping). So, unless `--strict` is used, the following does not produce
743a nested block quote in pandoc:
745 > This is a block quote.
746 >> Nested.
749Verbatim (code) blocks
750----------------------
752### Indented code blocks ###
754A block of text indented four spaces (or one tab) is treated as verbatim
755text: that is, special characters do not trigger special formatting,
756and all spaces and line breaks are preserved. For example,
758 if (a > 3) {
759 moveShip(5 * gravity, DOWN);
760 }
762The initial (four space or one tab) indentation is not considered part
763of the verbatim text, and is removed in the output.
765Note: blank lines in the verbatim text need not begin with four spaces.
768### Delimited code blocks ###
770*Pandoc extension*.
772In addition to standard indented code blocks, Pandoc supports
773*delimited* code blocks. These begin with a row of three or more
774tildes (`~`) and end with a row of tildes that must be at least
775as long as the starting row. Everything between the tilde-lines
776is treated as code. No indentation is necessary:
778 ~~~~~~~
779 if (a > 3) {
780 moveShip(5 * gravity, DOWN);
781 }
782 ~~~~~~~
784Like regular code blocks, delimited code blocks must be separated
785from surrounding text by blank lines.
787If the code itself contains a row of tildes, just use a longer
788row of tildes at the start and end:
790 ~~~~~~~~~~~~~~~~
791 ~~~~~~~~~~
792 code including tildes
793 ~~~~~~~~~~
794 ~~~~~~~~~~~~~~~~
796Optionally, you may specify the language of the code block using
797this syntax:
799 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines}
800 qsort [] = []
801 qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
802 qsort (filter (>= x) xs)
803 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
805Some output formats can use this information to do syntax highlighting.
806Currently, the only output format that uses this information is HTML.
808If pandoc has been compiled with syntax highlighting support, then the
809code block above will appear highlighted, with numbered lines. (To see
810which languages are supported, do `pandoc --version`.)
812If pandoc has not been compiled with syntax highlighting support, the
813code block above will appear as follows:
815 <pre class="haskell">
816 <code>
817 ...
818 </code>
819 </pre>
822Lists
823-----
825### Bullet lists ###
827A bullet list is a list of bulleted list items. A bulleted list
828item begins with a bullet (`*`, `+`, or `-`). Here is a simple
829example:
831 * one
832 * two
833 * three
835This will produce a "compact" list. If you want a "loose" list, in which
836each item is formatted as a paragraph, put spaces between the items:
838 * one
840 * two
842 * three
844The bullets need not be flush with the left margin; they may be
845indented one, two, or three spaces. The bullet must be followed
846by whitespace.
848List items look best if subsequent lines are flush with the first
849line (after the bullet):
851 * here is my first
852 list item.
853 * and my second.
855But markdown also allows a "lazy" format:
857 * here is my first
858 list item.
859 * and my second.
861### The four-space rule ###
863A list item may contain multiple paragraphs and other block-level
864content. However, subsequent paragraphs must be preceded by a blank line
865and indented four spaces or a tab. The list will look better if the first
866paragraph is aligned with the rest:
868 * First paragraph.
870 Continued.
872 * Second paragraph. With a code block, which must be indented
873 eight spaces:
875 { code }
877List items may include other lists. In this case the preceding blank
878line is optional. The nested list must be indented four spaces or
879one tab:
881 * fruits
882 + apples
883 - macintosh
884 - red delicious
885 + pears
886 + peaches
887 * vegetables
888 + brocolli
889 + chard
891As noted above, markdown allows you to write list items "lazily," instead of
892indenting continuation lines. However, if there are multiple paragraphs or
893other blocks in a list item, the first line of each must be indented.
895 + A lazy, lazy, list
896 item.
898 + Another one; this looks
899 bad but is legal.
901 Second paragraph of second
902 list item.
904**Note:** Although the four-space rule for continuation paragraphs
905comes from the official [markdown syntax guide], the reference implementation,
906`Markdown.pl`, does not follow it. So pandoc will give different results than
907`Markdown.pl` when authors have indented continuation paragraphs fewer than
908four spaces.
910The [markdown syntax guide] is not explicit whether the four-space
911rule applies to *all* block-level content in a list item; it only
912mentions paragraphs and code blocks. But it implies that the rule
913applies to all block-level content (including nested lists), and
914pandoc interprets it that way.
916 [markdown syntax guide]:
917 http://daringfireball.net/projects/markdown/syntax#list
919### Ordered lists ###
921Ordered lists work just like bulleted lists, except that the items
922begin with enumerators rather than bullets.
924In standard markdown, enumerators are decimal numbers followed
925by a period and a space. The numbers themselves are ignored, so
926there is no difference between this list:
928 1. one
929 2. two
930 3. three
932and this one:
934 5. one
935 7. two
936 1. three
938*Pandoc extension*.
940Unlike standard markdown, Pandoc allows ordered list items to be marked
941with uppercase and lowercase letters and roman numerals, in addition to
942arabic numerals. List markers may be enclosed in parentheses or followed by a
943single right-parentheses or period. They must be separated from the
944text that follows by at least one space, and, if the list marker is a
945capital letter with a period, by at least two spaces.[^2]
947[^2]: The point of this rule is to ensure that normal paragraphs
948 starting with people's initials, like
950 B. Russell was an English philosopher.
952 do not get treated as list items.
954 This rule will not prevent
956 (C) 2007 Joe Smith
958 from being interpreted as a list item. In this case, a backslash
959 escape can be used:
961 (C\) 2007 Joe Smith
963Pandoc also pays attention to the type of list marker used, and to the
964starting number, and both of these are preserved where possible in the
965output format. Thus, the following yields a list with numbers followed
966by a single parenthesis, starting with 9, and a sublist with lowercase
967roman numerals:
969 9) Ninth
970 10) Tenth
971 11) Eleventh
972 i. subone
973 ii. subtwo
974 iii. subthree
976Note that Pandoc pays attention only to the *starting* marker in a list.
977So, the following yields a list numbered sequentially starting from 2:
979 (2) Two
980 (5) Three
981 1. Four
982 * Five
984If default list markers are desired, use `#.`:
986 #. one
987 #. two
988 #. three
991### Definition lists ###
993*Pandoc extension*.
995Pandoc supports definition lists, using a syntax inspired by
996[PHP Markdown Extra] and [reStructuredText]:[^3]
998 Term 1
1000 : Definition 1
1002 Term 2 with *inline markup*
1004 : Definition 2
1006 { some code, part of Definition 2 }
1008 Third paragraph of definition 2.
1010Each term must fit on one line, which may optionally be followed by
1011a blank line, and must be followed by one or more definitions.
1012A definition begins with a colon or tilde, which may be indented one
1013or two spaces. A term may have multiple definitions, and each definition
1014may consist of one or more block elements (paragraph, code block, list,
1015etc.), each indented four spaces or one tab stop.
1017If you leave space after the definition (as in the example above),
1018the blocks of the definitions will be considered paragraphs. In some
1019output formats, this will mean greater spacing between term/definition
1020pairs. For a compact definition list, do not leave space between the
1021definition and the next term:
1023 Term 1
1024 ~ Definition 1
1025 Term 2
1026 ~ Definition 2a
1027 ~ Definition 2b
1029[^3]: I have also been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).
1031[PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
1034### Numbered example lists ###
1036*Pandoc extension*.
1038The special list marker `@` can be used for sequentially numbered
1039examples. The first list item with a `@` marker will be numbered '1',
1040the next '2', and so on, throughout the document. The numbered examples
1041need not occur in a single list; each new list using `@` will take up
1042where the last stopped. So, for example:
1044 (@) My first example will be numbered (1).
1045 (@) My second example will be numbered (2).
1047 Explanation of examples.
1049 (@) My third example will be numbered (3).
1051Numbered examples can be labeled and referred to elsewhere in the
1052document:
1054 (@good) This is a good example.
1056 As (@good) illustrates, ...
1058The label can be any string of alphanumeric characters, underscores,
1059or hyphens.
1062### Compact and loose lists ###
1064Pandoc behaves differently from `Markdown.pl` on some "edge
1065cases" involving lists. Consider this source:
1067 + First
1068 + Second:
1069 - Fee
1070 - Fie
1071 - Foe
1073 + Third
1075Pandoc transforms this into a "compact list" (with no `<p>` tags around
1076"First", "Second", or "Third"), while markdown puts `<p>` tags around
1077"Second" and "Third" (but not "First"), because of the blank space
1078around "Third". Pandoc follows a simple rule: if the text is followed by
1079a blank line, it is treated as a paragraph. Since "Second" is followed
1080by a list, and not a blank line, it isn't treated as a paragraph. The
1081fact that the list is followed by a blank line is irrelevant. (Note:
1082Pandoc works this way even when the `--strict` option is specified. This
1083behavior is consistent with the official markdown syntax description,
1084even though it is different from that of `Markdown.pl`.)
1087### Ending a list ###
1089What if you want to put an indented code block after a list?
1091 - item one
1092 - item two
1094 { my code block }
1096Trouble! Here pandoc (like other markdown implementations) will treat
1097`{ my code block }` as the second paragraph of item two, and not as
1098a code block.
1100To "cut off" the list after item two, you can insert some non-indented
1101content, like an HTML comment, which won't produce visible output in
1102any format:
1104 - item one
1105 - item two
1107 <!-- end of list -->
1109 { my code block }
1111You can use the same trick if you want two consecutive lists instead
1112of one big list:
1114 1. one
1115 2. two
1116 3. three
1118 <!-- -->
1120 a. uno
1121 b. dos
1122 c. tres
1125Horizontal rules
1126----------------
1128A line containing a row of three or more `*`, `-`, or `_` characters
1129(optionally separated by spaces) produces a horizontal rule:
1131 * * * *
1133 ---------------
1136Tables
1137------
1139*Pandoc extension*.
1141Three kinds of tables may be used. All three kinds presuppose the use of
1142a fixed-width font, such as Courier.
1144**Simple tables** look like this:
1146 Right Left Center Default
1147 ------- ------ ---------- -------
1148 12 12 12 12
1149 123 123 123 123
1150 1 1 1 1
1152 Table: Demonstration of simple table syntax.
1154The headers and table rows must each fit on one line. Column
1155alignments are determined by the position of the header text relative
1156to the dashed line below it:[^4]
1158 - If the dashed line is flush with the header text on the right side
1159 but extends beyond it on the left, the column is right-aligned.
1160 - If the dashed line is flush with the header text on the left side
1161 but extends beyond it on the right, the column is left-aligned.
1162 - If the dashed line extends beyond the header text on both sides,
1163 the column is centered.
1164 - If the dashed line is flush with the header text on both sides,
1165 the default alignment is used (in most cases, this will be left).
1167[^4]: This scheme is due to Michel Fortin, who proposed it on the
1168 [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).
1170The table must end with a blank line, or a line of dashes followed by
1171a blank line. A caption may optionally be provided (as illustrated in
1172the example above). A caption is a paragraph beginning with the string
1173`Table:` (or just `:`), which will be stripped off. It may appear either
1174before or after the table.
1176The column headers may be omitted, provided a dashed line is used
1177to end the table. For example:
1179 ------- ------ ---------- -------
1180 12 12 12 12
1181 123 123 123 123
1182 1 1 1 1
1183 ------- ------ ---------- -------
1185When headers are omitted, column alignments are determined on the basis
1186of the first line of the table body. So, in the tables above, the columns
1187would be right, left, center, and right aligned, respectively.
1189**Multiline tables** allow headers and table rows to span multiple lines
1190of text (but cells that span multiple columns or rows of the table are
1191not supported). Here is an example:
1193 -------------------------------------------------------------
1194 Centered Default Right Left
1195 Header Aligned Aligned Aligned
1196 ----------- ------- --------------- -------------------------
1197 First row 12.0 Example of a row that
1198 spans multiple lines.
1200 Second row 5.0 Here's another one. Note
1201 the blank line between
1202 rows.
1203 -------------------------------------------------------------
1205 Table: Here's the caption. It, too, may span
1206 multiple lines.
1208These work like simple tables, but with the following differences:
1210 - They must begin with a row of dashes, before the header text
1211 (unless the headers are omitted).
1212 - They must end with a row of dashes, then a blank line.
1213 - The rows must be separated by blank lines.
1215In multiline tables, the table parser pays attention to the widths of
1216the columns, and the writers try to reproduce these relative widths in
1217the output. So, if you find that one of the columns is too narrow in the
1218output, try widening it in the markdown source.
1220Headers may be omitted in multiline tables as well as simple tables:
1222 ----------- ------- --------------- -------------------------
1223 First row 12.0 Example of a row that
1224 spans multiple lines.
1226 Second row 5.0 Here's another one. Note
1227 the blank line between
1228 rows.
1229 -------------------------------------------------------------
1231 : Here's a multiline table without headers.
1233It is possible for a multiline table to have just one row, but the row
1234should be followed by a blank line (and then the row of dashes that ends
1235the table), or the table may be interpreted as a simple table.
1237**Grid tables** look like this:
1239 : Sample grid table.
1241 +---------------+---------------+--------------------+
1242 | Fruit | Price | Advantages |
1243 +===============+===============+====================+
1244 | Bananas | $1.34 | - built-in wrapper |
1245 | | | - bright color |
1246 +---------------+---------------+--------------------+
1247 | Oranges | $2.10 | - cures scurvy |
1248 | | | - tasty |
1249 +---------------+---------------+--------------------+
1251The row of `=`s separates the header from the table body, and can be
1252omitted for a headerless table. The cells of grid tables may contain
1253arbitrary block elements (multiple paragraphs, code blocks, lists,
1254etc.). Alignments are not supported, nor are cells that span multiple
1255columns or rows. Grid tables can be created easily using [Emacs table mode].
1257 [Emacs table mode]: http://table.sourceforge.net/
1260Title block
1261-----------
1263*Pandoc extension*.
1265If the file begins with a title block
1267 % title
1268 % author(s) (separated by semicolons)
1269 % date
1271it will be parsed as bibliographic information, not regular text. (It
1272will be used, for example, in the title of standalone LaTeX or HTML
1273output.) The block may contain just a title, a title and an author,
1274or all three elements. If you want to include an author but no
1275title, or a title and a date but no author, you need a blank line:
1278 % Author
1280 % My title
1282 % June 15, 2006
1284The title may occupy multiple lines, but continuation lines must
1285begin with leading space, thus:
1287 % My title
1288 on multiple lines
1290If a document has multiple authors, the authors may be put on
1291separate lines with leading space, or separated by semicolons, or
1292both. So, all of the following are equivalent:
1294 % Author One
1295 Author Two
1297 % Author One; Author Two
1299 % Author One;
1300 Author Two
1302The date must fit on one line.
1304All three metadata fields may contain standard inline formatting
1305(italics, links, footnotes, etc.).
1307Title blocks will always be parsed, but they will affect the output only
1308when the `--standalone` (`-s`) option is chosen. In HTML output, titles
1309will appear twice: once in the document head -- this is the title that
1310will appear at the top of the window in a browser -- and once at the
1311beginning of the document body. The title in the document head can have
1312an optional prefix attached (`--title-prefix` or `-T` option). The title
1313in the body appears as an H1 element with class "title", so it can be
1314suppressed or reformatted with CSS. If a title prefix is specified with
1315`-T` and no title block appears in the document, the title prefix will
1316be used by itself as the HTML title.
1318The man page writer extracts a title, man page section number, and
1319other header and footer information from the title line. The title
1320is assumed to be the first word on the title line, which may optionally
1321end with a (single-digit) section number in parentheses. (There should
1322be no space between the title and the parentheses.) Anything after
1323this is assumed to be additional footer and header text. A single pipe
1324character (`|`) should be used to separate the footer text from the header
1325text. Thus,
1327 % PANDOC(1)
1329will yield a man page with the title `PANDOC` and section 1.
1331 % PANDOC(1) Pandoc User Manuals
1333will also have "Pandoc User Manuals" in the footer.
1335 % PANDOC(1) Pandoc User Manuals | Version 4.0
1337will also have "Version 4.0" in the header.
1340Backslash escapes
1341-----------------
1343Except inside a code block or inline code, any punctuation or space
1344character preceded by a backslash will be treated literally, even if it
1345would normally indicate formatting. Thus, for example, if one writes
1347 *\*hello\**
1349one will get
1351 <em>*hello*</em>
1353instead of
1355 <strong>hello</strong>
1357This rule is easier to remember than standard markdown's rule,
1358which allows only the following characters to be backslash-escaped:
1360 \`*_{}[]()>#+-.!
1362(However, if the `--strict` option is supplied, the standard
1363markdown rule will be used.)
1365A backslash-escaped space is parsed as a nonbreaking space. It will
1366appear in TeX output as `~` and in HTML and XML as `\&#160;` or
1367`\&nbsp;`.
1369A backslash-escaped newline (i.e. a backslash occurring at the end of
1370a line) is parsed as a hard line break. It will appear in TeX output as
1371`\\` and in HTML as `<br />`. This is a nice alternative to
1372markdown's "invisible" way of indicating hard line breaks using
1373two trailing spaces on a line.
1375Backslash escapes do not work in verbatim contexts.
1377Smart punctuation
1378-----------------
1380If the `--smart` option is specified, pandoc will produce typographically
1381correct output, converting straight quotes to curly quotes, `---` and `--`
1382to Em-dashes, and `...` to ellipses. Nonbreaking spaces are inserted after
1383certain abbreviations, such as "Mr."
1385Inline formatting
1386-----------------
1388### Emphasis ###
1390To *emphasize* some text, surround it with `*`s or `_`, like this:
1392 This text is _emphasized with underscores_, and this
1393 is *emphasized with asterisks*.
1395Double `*` or `_` produces **strong emphasis**:
1397 This is **strong emphasis** and __with underscores__.
1399A `*` or `_` character surrounded by spaces, or backslash-escaped,
1400will not trigger emphasis:
1402 This is * not emphasized *, and \*neither is this\*.
1404Because `_` is sometimes used inside words and identifiers,
1405pandoc does not interpret a `_` surrounded by alphanumeric
1406characters as an emphasis marker. If you want to emphasize
1407just part of a word, use `*`:
1409 feas*ible*, not feas*able*.
1412### Strikeout ###
1414*Pandoc extension*.
1416To strikeout a section of text with a horizontal line, begin and end it
1417with `~~`. Thus, for example,
1419 This ~~is deleted text.~~
1422### Superscripts and subscripts ###
1424*Pandoc extension*.
1426Superscripts may be written by surrounding the superscripted text by `^`
1427characters; subscripts may be written by surrounding the subscripted
1428text by `~` characters. Thus, for example,
1430 H~2~O is a liquid. 2^10^ is 1024.
1432If the superscripted or subscripted text contains spaces, these spaces
1433must be escaped with backslashes. (This is to prevent accidental
1434superscripting and subscripting through the ordinary use of `~` and `^`.)
1435Thus, if you want the letter P with 'a cat' in subscripts, use
1436`P~a\ cat~`, not `P~a cat~`.
1439### Verbatim ###
1441To make a short span of text verbatim, put it inside backticks:
1443 What is the difference between `>>=` and `>>`?
1445If the verbatim text includes a backtick, use double backticks:
1447 Here is a literal backtick `` ` ``.
1449(The spaces after the opening backticks and before the closing
1450backticks will be ignored.)
1452The general rule is that a verbatim span starts with a string
1453of consecutive backticks (optionally followed by a space)
1454and ends with a string of the same number of backticks (optionally
1455preceded by a space).
1457Note that backslash-escapes (and other markdown constructs) do not
1458work in verbatim contexts:
1460 This is a backslash followed by an asterisk: `\*`.
1463Math
1464----
1466*Pandoc extension*.
1468Anything between two `$` characters will be treated as TeX math. The
1469opening `$` must have a character immediately to its right, while the
1470closing `$` must have a character immediately to its left. Thus,
1471`$20,000 and $30,000` won't parse as math. If for some reason
1472you need to enclose text in literal `$` characters, backslash-escape
1473them and they won't be treated as math delimiters.
1475TeX math will be printed in all output formats. How it is rendered
1476depends on the output format:
1478Markdown, reStructuredText, LaTeX, Org-Mode, ConTeXt
1479 ~ It will appear verbatim between `$` characters.
1481reStructuredText
1482 ~ It will be rendered using an interpreted text role `:math:`, as described
1483 [here](http://www.american.edu/econ/itex2mml/mathhack.rst).
1485Texinfo
1486 ~ It will be rendered inside a `@math` command.
1488groff man
1489 ~ It will be rendered verbatim without `$`'s.
1491MediaWiki
1492 ~ It will be rendered inside `<math>` tags.
1494Textile
1495 ~ It will be rendered inside `<span class="math">` tags.
1497RTF, Docbook, OpenDocument, ODT
1498 ~ It will be rendered, if possible, using unicode characters,
1499 and will otherwise appear verbatim.
1501HTML, Slidy, S5, EPUB
1502 ~ The way math is rendered in HTML will depend on the
1503 command-line options selected:
1505 1. The default is to render TeX math as far as possible using unicode
1506 characters, as with RTF, Docbook, and OpenDocument output. Formulas
1507 are put inside a `span` with `class="math"`, so that they may be
1508 styled differently from the surrounding text if needed.
1510 2. If the `--latexmathml` option is used, TeX math will be displayed
1511 between $ or $$ characters and put in `<span>` tags with class `LaTeX`.
1512 The [LaTeXMathML] script will be used to render it as formulas.
1513 (This trick does not work in all browsers, but it works in Firefox.
1514 In browsers that do not support LaTeXMathML, TeX math will appear
1515 verbatim between $ characters.)
1517 3. If the `--jsmath` option is used, TeX math will be put inside
1518 `<span>` tags (for inline math) or `<div>` tags (for display math)
1519 with class `math`. The [jsMath] script will be used to render
1520 it.
1522 4. If the `--mimetex` option is used, the [mimeTeX] CGI script will
1523 be called to generate images for each TeX formula. This should
1524 work in all browsers. The `--mimetex` option takes an optional URL
1525 as argument. If no URL is specified, it will be assumed that the
1526 mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
1528 5. If the `--gladtex` option is used, TeX formulas will be enclosed
1529 in `<eq>` tags in the HTML output. The resulting `htex` file may then
1530 be processed by [gladTeX], which will produce image files for each
1531 formula and an `html` file with links to these images. So, the
1532 procedure is:
1534 pandoc -s --gladtex myfile.txt -o myfile.htex
1535 gladtex -d myfile-images myfile.htex
1536 # produces myfile.html and images in myfile-images
1538 6. If the `--webtex` option is used, TeX formulas will be converted
1539 to `<img>` tags that link to an external script that converts
1540 formulas to images. The formula will be URL-encoded and concatenated
1541 with the URL provided. If no URL is specified, the Google Chart
1542 API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).
1545Raw HTML
1546--------
1548Markdown allows you to insert raw HTML anywhere in a document
1549(except verbatim contexts, where `<`, `>`, and `&` are interpreted
1550literally).
1552The raw HTML is passed through unchanged in HTML, S5, Slidy, EPUB,
1553Markdown, and Textile output, and suppressed in other formats.
1555*Pandoc extension*.
1557Standard markdown allows you to include HTML "blocks": blocks
1558of HTML between balanced tags that are separated from the surrounding text
1559with blank lines, and start and end at the left margin. Within
1560these blocks, everything is interpreted as HTML, not markdown;
1561so (for example), `*` does not signify emphasis.
1563Pandoc behaves this way when `--strict` is specified; but by default,
1564pandoc interprets material between HTML block tags as markdown.
1565Thus, for example, Pandoc will turn
1567 <table>
1568 <tr>
1569 <td>*one*</td>
1570 <td>[a link](http://google.com)</td>
1571 </tr>
1572 </table>
1574into
1576 <table>
1577 <tr>
1578 <td><em>one</em></td>
1579 <td><a href="http://google.com">a link</a></td>
1580 </tr>
1581 </table>
1583whereas `Markdown.pl` will preserve it as is.
1585There is one exception to this rule: text between `<script>` and
1586`<style>` tags is not interpreted as markdown.
1588This departure from standard markdown should make it easier to mix
1589markdown with HTML block elements. For example, one can surround
1590a block of markdown text with `<div>` tags without preventing it
1591from being interpreted as markdown.
1594Raw TeX
1595-------
1597*Pandoc extension*.
1599In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be
1600included in a document. Inline TeX commands will be preserved and passed
1601unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use
1602LaTeX to include BibTeX citations:
1604 This result was proved in \cite{jones.1967}.
1606Note that in LaTeX environments, like
1608 \begin{tabular}{|l|l|}\hline
1609 Age & Frequency \\ \hline
1610 18--25 & 15 \\
1611 26--35 & 33 \\
1612 36--45 & 22 \\ \hline
1613 \end{tabular}
1615the material between the begin and end tags will be interpreted as raw
1616LaTeX, not as markdown.
1618Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
1619and ConTeXt.
1621### Macros ###
1623For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and
1624`\renewcommand` definitions and apply the resulting macros to all LaTeX
1625math. So, for example, the following will work in all output formats,
1626not just LaTeX:
1628 \newcommand{\tuple}[1]{\langle #1 \rangle}
1630 $\tuple{a, b, c}$
1632In LaTeX output, the `\newcommand` definition will simply be passed
1633unchanged to the output.
1636Links
1637-----
1639Markdown allows links to be specified in several ways.
1641### Automatic links ###
1643If you enclose a URL or email address in pointy brackets, it
1644will become a link:
1646 <http://google.com>
1647 <sam@green.eggs.ham>
1650### Inline links ###
1652An inline link consists of the link text in square brackets,
1653followed by the URL in parentheses. (Optionally, the URL can
1654be followed by a link title, in quotes.)
1656 This is an [inline link](/url), and here's [one with
1657 a title](http://fsf.org "click here for a good time!").
1659There can be no space between the bracketed part and the parenthesized part.
1660The link text can contain formatting (such as emphasis), but the title cannot.
1663### Reference links ###
1665An *explicit* reference link has two parts, the link itself and the link
1666definition, which may occur elsewhere in the document (either
1667before or after the link).
1669The link consists of link text in square brackets, followed by a label in
1670square brackets. (There can be space between the two.) The link definition
1671must begin at the left margin or indented no more than three spaces. It
1672consists of the bracketed label, followed by a colon and a space, followed by
1673the URL, and optionally (after a space) a link title either in quotes or in
1674parentheses.
1676Here are some examples:
1678 [my label 1]: /foo/bar.html "My title, optional"
1679 [my label 2]: /foo
1680 [my label 3]: http://fsf.org (The free software foundation)
1681 [my label 4]: /bar#special 'A title in single quotes'
1683The URL may optionally be surrounded by angle brackets:
1685 [my label 5]: <http://foo.bar.baz>
1687The title may go on the next line:
1689 [my label 3]: http://fsf.org
1690 "The free software foundation"
1692Note that link labels are not case sensitive. So, this will work:
1694 Here is [my link][FOO]
1696 [Foo]: /bar/baz
1698In an *implicit* reference link, the second pair of brackets is
1699empty, or omitted entirely:
1701 See [my website][], or [my website].
1703 [my website]: http://foo.bar.baz
1706Images
1707------
1709A link immediately preceded by a `!` will be treated as an image.
1710The link text will be used as the image's alt text:
1712 ![la lune](lalune.jpg "Voyage to the moon")
1714 ![movie reel]
1716 [movie reel]: movie.gif
1718### Pictures with captions ###
1720*Pandoc extension*.
1722An image occurring by itself in a paragraph will be rendered as
1723a figure with a caption.[^5] (In LaTeX, a figure environment will be
1724used; in HTML, the image will be placed in a `div` with class
1725`figure`, together with a caption in a `p` with class `caption`.)
1726The image's alt text will be used as the caption.
1728 ![This is the caption](/url/of/image.png)
1730[^5]: This feature is not yet implemented for RTF, OpenDocument, or
1731 ODT. In those formats, you'll just get an image in a paragraph by
1732 itself, with no caption.
1734If you just want a regular inline image, just make sure it is not
1735the only thing in the paragraph. One way to do this is to insert a
1736nonbreaking space after the image:
1738 ![This image won't be a figure](/url/of/image.png)\
1741Footnotes
1742---------
1744*Pandoc extension*.
1746Pandoc's markdown allows footnotes, using the following syntax:
1748 Here is a footnote reference,[^1] and another.[^longnote]
1750 [^1]: Here is the footnote.
1752 [^longnote]: Here's one with multiple blocks.
1754 Subsequent paragraphs are indented to show that they
1755 belong to the previous footnote.
1757 { some.code }
1759 The whole paragraph can be indented, or just the first
1760 line. In this way, multi-paragraph footnotes work like
1761 multi-paragraph list items.
1763 This paragraph won't be part of the note, because it
1764 isn't indented.
1766The identifiers in footnote references may not contain spaces, tabs,
1767or newlines. These identifiers are used only to correlate the
1768footnote reference with the note itself; in the output, footnotes
1769will be numbered sequentially.
1771The footnotes themselves need not be placed at the end of the
1772document. They may appear anywhere except inside other block elements
1773(lists, block quotes, tables, etc.).
1775Inline footnotes are also allowed (though, unlike regular notes,
1776they cannot contain multiple paragraphs). The syntax is as follows:
1778 Here is an inline note.^[Inlines notes are easier to write, since
1779 you don't have to pick an identifier and move down to type the
1780 note.]
1782Inline and regular footnotes may be mixed freely.
1785Citations
1786---------
1788*Pandoc extension*.
1790Pandoc can automatically generate citations and a bibliography in a number of
1791styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature,
1792you will need a bibliographic database in one of the following formats:
1794 Format File extension
1795 ------------ --------------
1796 MODS .mods
1797 BibTeX .bib
1798 BibLaTeX .bbx
1799 RIS .ris
1800 EndNote .enl
1801 EndNote XML .xml
1802 ISI .wos
1803 MEDLINE .medline
1804 Copac .copac
1805 JSON citeproc .json
1807You will need to specify the bibliography file using the `--bibliography`
1808command-line option (which may be repeated if you have several
1809bibliographies).
1811By default, pandoc will use a Chicago author-date format for citations
1812and references. To use another style, you will need to use the
1813`--csl` option to specify a [CSL] 1.0 style file. A primer on
1814creating and modifying CSL styles can be found at
1815<http://citationstyles.org/downloads/primer.html>.
1816A repository of CSL styles can be found at
1817<https://github.com/citation-style-language/styles>.
1819Citations go inside square brackets and are separated by semicolons.
1820Each citation must have a key, composed of '@' + the citation
1821identifier from the database, and may optionally have a prefix,
1822a locator, and a suffix. Here are some examples:
1824 Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].
1826 Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].
1828 Blah blah [@smith04; @doe99].
1830A minus sign (`-`) before the `@` will suppress mention of
1831the author in the citation. This can be useful when the
1832author is already mentioned in the text:
1834 Smith says blah [-@smith04].
1836You can also write an in-text citation, as follows:
1838 @smith04 says blah.
1840 @smith04 [p. 33] says blah.
1842If the style calls for a list of works cited, it will be placed
1843at the end of the document. Normally, you will want to end your
1844document with an appropriate header:
1846 last paragraph...
1848 # References
1850The bibliography will be inserted after this header.
1853Producing HTML slide shows with Pandoc
1854======================================
1856You can use Pandoc to produce an HTML + javascript slide presentation
1857that can be viewed via a web browser. There are two ways to do this,
1858using [S5] or [Slidy].
1860Here's the markdown source for a simple slide show, `eating.txt`:
1862 % Eating Habits
1863 % John Doe
1864 % March 22, 2005
1866 # In the morning
1868 - Eat eggs
1869 - Drink coffee
1871 # In the evening
1873 - Eat spaghetti
1874 - Drink wine
1876 --------------------------
1878 ![picture of spaghetti](images/spaghetti.jpg)
1880To produce the slide show, simply type
1882 pandoc -w s5 -s eating.txt > eating.html
1884for S5, or
1886 pandoc -w slidy -s eating.txt > eating.html
1888for Slidy.
1890A title page is constructed automatically from the document's title
1891block. Each level-one header and horizontal rule begins a new slide.
1893The file produced by pandoc with the `-s/--standalone` option embeds a
1894link to javascripts and CSS files, which are assumed to be available at
1895the relative path `ui/default` (for S5) or at the Slidy website at
1896`w3.org` (for Slidy). If the `--offline` option is specified, the
1897scripts and CSS will be included directly in the generated file, so that
1898it may be used offline.
1900You can change the style of the slides by putting customized CSS files
1901in `$DATADIR/s5/default` (for S5) or `$DATADIR/slidy` (for Slidy),
1902where `$DATADIR` is the user data directory (see `--data-dir`, above).
1903The originals may be found in pandoc's system data directory (generally
1904`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any
1905files it does not find in the user data directory.
1907Incremental lists
1908-----------------
1910By default, these writers produces lists that display "all at once."
1911If you want your lists to display incrementally (one item at a time),
1912use the `-i` option. If you want a particular list to depart from the
1913default (that is, to display incrementally without the `-i` option and
1914all at once with the `-i` option), put it in a block quote:
1916 > - Eat spaghetti
1917 > - Drink wine
1919In this way incremental and nonincremental lists can be mixed in
1920a single document.
1922Literate Haskell support
1923========================
1925If you append `+lhs` to an appropriate input or output format (`markdown`,
1926`rst`, or `latex` for input or output; `html` for output only), pandoc
1927will treat the document as literate Haskell source. This means that
1929 - In markdown input, "bird track" sections will be parsed as Haskell
1930 code rather than block quotations. Text between `\begin{code}`
1931 and `\end{code}` will also be treated as Haskell code.
1933 - In markdown output, code blocks with class `haskell` will be
1934 rendered using bird tracks, and block quotations will be
1935 indented one space, so they will not be treated as Haskell code.
1936 In addition, headers will be rendered setext-style (with underlines)
1937 rather than atx-style (with '#' characters). (This is because ghc
1938 treats '#' characters in column 1 as introducing line numbers.)
1940 - In restructured text input, "bird track" sections will be parsed
1941 as Haskell code.
1943 - In restructured text output, code blocks with class `haskell` will
1944 be rendered using bird tracks.
1946 - In LaTeX input, text in `code` environments will be parsed as
1947 Haskell code.
1949 - In LaTeX output, code blocks with class `haskell` will be rendered
1950 inside `code` environments.
1952 - In HTML output, code blocks with class `haskell` will be rendered
1953 with class `literatehaskell` and bird tracks.
1955Examples:
1957 pandoc -f markdown+lhs -t html
1959reads literate Haskell source formatted with markdown conventions and writes
1960ordinary HTML (without bird tracks).
1962 pandoc -f markdown+lhs -t html+lhs
1964writes HTML with the Haskell code in bird tracks, so it can be copied
1965and pasted as literate Haskell source.
1967Authors
1968=======
1970© 2006-2011 John MacFarlane (jgm at berkeley dot edu). Released under the
1971[GPL], version 2 or greater. This software carries no warranty of
1972any kind. (See COPYRIGHT for full copyright and warranty notices.)
1973Other contributors include Recai Oktaş, Paulo Tanimoto, Peter Wang,
1974Andrea Rossato, Eric Kow, infinity0x, Luke Plant, shreevatsa.public,
1975Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton,
1976Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner.
1978[markdown]: http://daringfireball.net/projects/markdown/
1979[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
1980[S5]: http://meyerweb.com/eric/tools/s5/
1981[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
1982[HTML]: http://www.w3.org/TR/html40/
1983[LaTeX]: http://www.latex-project.org/
1984[ConTeXt]: http://www.pragma-ade.nl/
1985[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
1986[DocBook XML]: http://www.docbook.org/
1987[OpenDocument XML]: http://opendocument.xml.org/
1988[ODT]: http://en.wikipedia.org/wiki/OpenDocument
1989[Textile]: http://redcloth.org/textile
1990[MediaWiki markup]: http://www.mediawiki.org/wiki/Help:Formatting
1991[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html
1992[Haskell]: http://www.haskell.org/
1993[GNU Texinfo]: http://www.gnu.org/software/texinfo/
1994[Emacs Org-Mode]: http://orgmode.org
1995[EPUB]: http://www.idpf.org/
1996[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"