git.iko.soy/typeable/pandoc
on 2df0331 help sign in
854 lines 32 kB history raw
1% Pandoc User's Guide
2% John MacFarlane
3% July 14, 2007
5Pandoc is a [Haskell] library for converting from one markup format to
6another, and a command-line tool that uses this library. It can read
7[markdown] and (subsets of) [reStructuredText], [HTML], and [LaTeX], and
8it can write [markdown], [reStructuredText], [HTML], [LaTeX], [ConTeXt],
9[RTF], [DocBook XML], [groff man] pages, and [S5] HTML slide shows.
10Pandoc's version of markdown contains some enhancements, like footnotes
11and embedded LaTeX.
13In contrast to existing tools for converting markdown to HTML, which
14use regex substitutions, Pandoc has a modular design: it consists of a
15set of readers, which parse text in a given format and produce a native
16representation of the document, and a set of writers, which convert
17this native representation into a target format. Thus, adding an input
18or output format requires only adding a reader or writer.
20[markdown]: http://daringfireball.net/projects/markdown/
21[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
22[S5]: http://meyerweb.com/eric/tools/s5/
23[HTML]: http://www.w3.org/TR/html40/
24[LaTeX]: http://www.latex-project.org/
25[ConTeXt]: http://www.pragma-ade.nl/
26[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
27[DocBook XML]: http://www.docbook.org/
28[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html
29[Haskell]: http://www.haskell.org/
31(c) 2006 John MacFarlane (jgm at berkeley dot edu). Released under the
32[GPL], version 2 or greater. This software carries no warranty of
33any kind. (See COPYRIGHT for full copyright and warranty notices.)
34Recai Oktaş (roktas at debian dot org) deserves credit for the build
35system, the debian package, and the robust wrapper scripts.
37[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
39Requirements
40============
42The `pandoc` program itself does not depend on any external libraries
43or programs.
45The wrapper script `html2markdown` requires
47 - `pandoc` (which must be in the PATH)
48 - a POSIX-compliant shell (installed by default on all linux and unix
49 systems, including Mac OS X, and in [Cygwin] for Windows),
50 - `HTML Tidy`
51 - `iconv` (for character encoding conversion). (If `iconv` is absent,
52 `html2markdown` will still work, but it will treat everything as UTF-8.)
54The wrapper script `markdown2pdf` requires
56 - `pandoc` (which must be in the PATH)
57 - a POSIX-compliant shell
58 - `pdflatex`, which should be part of any [LaTeX] distribution
59 - the following LaTeX packages (available from [CTAN], if they
60 are not already included in your LaTeX distribution):
61 + `unicode` (for UTF8 characters)
62 + `fancyvrb` (for verbatim text in footnotes)
63 + `graphicx` (for images)
64 + `array` (for tables)
65 + `ulem` (for strikeout text)
67The wrapper script `hsmarkdown` requires only a POSIX-compliant shell.
69[Cygwin]: http://www.cygwin.com/
70[HTML Tidy]: http://tidy.sourceforge.net/
71[`iconv`]: http://www.gnu.org/software/libiconv/
72[CTAN]: http://www.ctan.org "Comprehensive TeX Archive Network"
74Using Pandoc
75============
77If you run `pandoc` without arguments, it will accept input from
78STDIN. If you run it with file names as arguments, it will take input
79from those files. By default, `pandoc` writes its output to STDOUT.
80If you want to write to a file, use the `-o` option:
82 pandoc -o hello.html hello.txt
84Note that you can specify multiple input files on the command line.
85`pandoc` will concatenate them all (with blank lines between them)
86before parsing:
88 pandoc -s chapter1.txt chapter2.txt references.txt > book.html
90(The `-s` option here tells `pandoc` to produce a standalone HTML file,
91with a proper header, rather than a fragment. For more details on this
92and many other command-line options, see below.)
94The format of the input and output can be specified explicitly using
95command-line options. The input format can be specified using the
96`-r/--read` or `-f/--from` options, the output format using the
97`-w/--write` or `-t/--to` options. Thus, to convert `hello.txt` from
98markdown to LaTeX, you could type:
100 pandoc -f markdown -t latex hello.txt
102To convert `hello.html` from html to markdown:
104 pandoc -f html -t markdown hello.html
106Supported output formats include `markdown`, `latex`, `context`
107(ConTeXt), `html`, `rtf` (rich text format), `rst` (reStructuredText),
108`docbook` (DocBook XML), `man` (groff man), and `s5` (which produces an
109HTML file that acts like powerpoint). Supported input formats include
110`markdown`, `html`, `latex`, and `rst`. Note that the `rst` reader only
111parses a subset of reStructuredText syntax. For example, it doesn't
112handle tables, definition lists, option lists, or footnotes. It handles
113only the constructs expressible in unextended markdown. But for simple
114documents it should be adequate. The `latex` and `html` readers are also
115limited in what they can do. Because the `html` reader is picky about
116the HTML it parses, it is recommended that you pipe HTML through [HTML
117Tidy] before sending it to `pandoc`, or use the `html2markdown` script
118described below.
120If you don't specify a reader or writer explicitly, `pandoc` will
121try to determine the input and output format from the extensions of
122the input and output filenames. Thus, for example,
124 pandoc -o hello.tex hello.txt
126will convert `hello.txt` from markdown to LaTeX. If no output file
127is specified (so that output goes to STDOUT), or if the output file's
128extension is unknown, the output format will default to HTML.
129If no input file is specified (so that input comes from STDIN), or
130if the input files' extensions are unknown, the input format will
131be assumed to be markdown unless explicitly specified.
133Character encodings
134-------------------
136All input is assumed to be in the UTF-8 encoding, and all output
137is in UTF-8. If your local character encoding is not UTF-8 and you use
138accented or foreign characters, you should pipe the input and output
139through [`iconv`]. For example,
141 iconv -t utf-8 source.txt | pandoc | iconv -f utf-8 > output.html
143will convert `source.txt` from the local encoding to UTF-8, then
144convert it to HTML, then convert back to the local encoding,
145putting the output in `output.html`.
147The shell scripts (described below) automatically convert the input
148from the local encoding to UTF-8 before running them through `pandoc`,
149then convert the output back to the local encoding.
151Shell scripts
152=============
154Three shell scripts, `markdown2pdf`, `html2markdown`, and `hsmarkdown`,
155are included in the standard Pandoc installation. (They are not included
156in the Windows binary package, as they require a POSIX shell, but they
157may be used in Windows under Cygwin.)
1591. `markdown2pdf` produces a PDF file from markdown-formatted
160 text, using `pandoc` and `pdflatex`. The default
161 behavior of `markdown2pdf` is to create a file with the same
162 base name as the first argument and the extension `pdf`; thus,
163 for example,
165 markdown2pdf sample.txt endnotes.txt
167 will produce `sample.pdf`. (If `sample.pdf` exists already,
168 it will be backed up before being overwritten.) An output file
169 name can be specified explicitly using the `-o` option:
171 markdown2pdf -o "My Book.pdf" chap1.txt chap2.txt chap3.txt
173 If no input file is specified, input will be taken from STDIN.
174 All of `pandoc`'s options will work with `markdown2pdf` as well.
1762. `html2markdown` grabs a web page from a file or URL and converts
177 it to markdown-formatted text, using `tidy` and `pandoc`.
179 All of `pandoc`'s options will work with `html2markdown` as well.
180 In addition, the following special options may be used.
181 The special options must be separated from the `html2markdown`
182 command and any regular Pandoc options by the delimiter `--`:
184 html2markdown -o out.txt -- -e latin1 -g curl google.com
186 The `-e` or `--encoding` option specifies the character encoding
187 of the HTML input. If this option is not specified, and input
188 is not from STDIN, `html2markdown` will attempt to determine the
189 page's character encoding from the "Content-type" meta tag.
190 If this is not present, UTF-8 is assumed.
192 The `-g` or `--grabber` option specifies the command to be used to
193 fetch the contents of a URL:
195 html2markdown -g 'curl --user foo:bar' www.mysite.com
197 If this option is not specified, `html2markdown` searches for an
198 available program (`wget`, `curl`, or a text-mode browser) to fetch
199 the contents of a URL.
2013. `hsmarkdown` is designed to be used as a drop-in replacement for
202 `Markdown.pl`. It forces `pandoc` to convert from markdown to
203 HTML, and to use the `--strict` flag for maximal compliance with
204 official markdown syntax. (All of Pandoc's syntax extensions and
205 variants, described below, are disabled.) No other command-line
206 options are allowed. (In fact, options will be interpreted as
207 filenames.)
209 As an alternative to using the `hsmarkdown` shell script, the
210 user may create a symbolic link to `pandoc` called `hsmarkdown`.
211 When invoked under the name `hsmarkdown`, `pandoc` will behave
212 as if the `--strict` flag had been selected, and no command-line
213 options will be recognized. However, this approach does not work
214 under Cygwin, due to problems with its simulation of symbolic
215 links.
217Command-line options
218====================
220Various command-line options can be used to customize the output.
221For further documentation, see the `pandoc(1)` man page.
223`-f`, `--from`, `-r`, or `--read` can be used to specify the input
224format -- the format Pandoc will be converting *from*. Available
225formats are `native`, `markdown`, `rst`, `html`, and `latex`.
227`-t`, `--to`, `-w`, or `--write` can be used to specify the output
228format -- the format Pandoc will be converting *to*. Available formats
229are `native`, `html`, `s5`, `docbook`, `latex`, `context`, `markdown`,
230`rst`, and `rtf`.
232`-s` or `--standalone` indicates that a standalone document is to be
233produced (with appropriate headers and footers), rather than a fragment.
235`-o` or `--output` specifies the name of the output file. If this
236option is not specified, or if its argument is `-`, output will be sent
237to STDOUT.
239`-p` or `--preserve-tabs` causes tabs in the source text to be
240preserved, rather than converted to spaces (the default).
242`--tabstop` allows the user to set the tab stop (which defaults to 4).
244`--strict` specifies that strict markdown syntax is to be used, without
245pandoc's usual extensions and variants (described below).
247`--reference-links` causes reference-style links to be used in markdown
248and reStructuredText output. By default inline links are used.
250`-R` or `--parse-raw` causes the HTML and LaTeX readers to parse HTML
251codes and LaTeX environments that it can't translate as raw HTML or
252LaTeX. Raw HTML can be printed in markdown, reStructuredText, HTML,
253and S5 output; raw LaTeX can be printed in markdown, reStructuredText,
254LaTeX, and ConTeXt output. The default is for the readers to omit
255untranslatable HTML codes and LaTeX environments. (The LaTeX reader
256does pass through untranslatable LaTeX commands, even if `-R` is not
257specified.)
259`-C` or `--custom-header` can be used to specify a custom document
260header. To see the headers used by default, use the `-D` option:
261for example, `pandoc -D html` prints the default HTML header.
263`--toc` or `--table-of-contents` includes an automatically generated
264table of contents (or, in the case of `latex`, `context`, and `rst`, an
265instruction to create one) in the output document. This option has no
266effect with `man`, `docbook`, or `s5` output formats.
268`-c` or `--css` allows the user to specify a custom stylesheet that
269will be linked to in HTML and S5 output.
271`-H` or `--include-in-header` specifies a file to be included
272(verbatim) at the end of the document header. This can be used, for
273example, to include special CSS or javascript in HTML documents.
275`-B` or `--include-before-body` specifies a file to be included
276(verbatim) at the beginning of the document body (e.g. after the `<body>`
277tag in HTML, or the `\begin{document}` command in LaTeX). This can be
278used to include navigation bars or banners in HTML documents.
280`-A` or `--include-after-body` specifies a file to be included
281(verbatim) at the end of the document body (before the `</body>` tag in
282HTML, or the `\end{document}` command in LaTeX).
284`-T` or `--title-prefix` specifies a string to be included as a prefix
285at the beginning of the title that appears in the HTML header (but not
286in the title as it appears at the beginning of the HTML body). (See
287below on Titles.)
289`-S` or `--smart` causes `pandoc` to produce typographically
290correct output, along the lines of John Gruber's [Smartypants].
291Straight quotes are converted to curly quotes, `---` to dashes, and
292`...` to ellipses. (Note: This option is only significant when
293the input format is `markdown`. It is selected automatically
294when the output format is `latex` or `context`.)
296[Smartypants]: http://daringfireball.net/projects/smartypants/
298`-m` or `--asciimathml` will cause LaTeX formulas (between $ signs) in
299HTML or S5 to display as formulas rather than as code. The trick will
300not work in all browsers, but it works in Firefox. Peter Jipsen's
301[ASCIIMathML] script is used to do the magic.
303[ASCIIMathML]: http://www1.chapman.edu/~jipsen/mathml/asciimath.html
305`-i` or `--incremental` causes all lists in S5 output to be displayed
306incrementally by default (one item at a time). The normal default
307is for lists to be displayed all at once.
309`-N` or `--number-sections` causes sections to be numbered in LaTeX
310or ConTeXt output. By default, sections are not numbered.
312`--dump-args` is intended to make it easier to create wrapper scripts
313that use Pandoc. It causes Pandoc to dump information about the arguments
314with which it was called to STDOUT, then exit. The first line printed
315is the name of the output file specified using the `-o` or `--output`
316option, or `-` if output would go to STDOUT. The remaining lines, if any,
317list command-line arguments. These will include the names of input
318files and any special options passed after ` -- ` on the command line.
319So, for example,
321 pandoc --dump-args -o foo.html -s foo.txt appendix.txt -- -e latin1
323will cause the following to be printed to STDOUT:
325 foo.html
326 foo.txt
327 appendix.txt
328 -e
329 latin1
331`--ignore-args` causes Pandoc to ignore all command-line arguments.
332Regular Pandoc options are not ignored. Thus, for example,
334 pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
336is equivalent to
338 pandoc -o foo.html -s
340`-v` or `--version` prints the version number to STDERR.
342`-h` or `--help` prints a usage message to STDERR.
344Pandoc's markdown vs. standard markdown
345=======================================
347In parsing markdown, Pandoc departs from and extends [standard markdown]
348in a few respects. (To run Pandoc on the official markdown test suite,
349type `make test-markdown`.) Except where noted, these differences can
350be suppressed by specifying the `--strict` command-line option or by
351using the `hsmarkdown` wrapper.
353[standard markdown]: http://daringfireball.net/projects/markdown/syntax
354 "Markdown syntax description"
356Backslash escapes
357-----------------
359Except inside a code block or inline code, any punctuation or space
360character preceded by a backslash will be treated literally, even if it
361would normally indicate formatting. Thus, for example, if one writes
363 *\*hello\**
365one will get
367 <em>*hello*</em>
369instead of
371 <strong>hello</strong>
373This rule is easier to remember than standard markdown's rule,
374which allows only the following characters to be backslash-escaped:
376 \`*_{}[]()>#+-.!
378Subscripts and superscripts
379---------------------------
381Superscripts may be written by surrounding the superscripted text by `^`
382characters; subscripts may be written by surrounding the subscripted
383text by `~` characters. Thus, for example,
385 H~2~O is a liquid. 2^10^ is 1024.
387If the superscripted or subscripted text contains spaces, these spaces
388must be escaped with backslashes. (This is to prevent accidental
389superscripting and subscripting through the ordinary use of `~` and `^`.)
390Thus, if you want the letter P with 'a cat' in subscripts, use
391`P~a\ cat`, not `P~a cat~`.
393Strikeout
394---------
396To strikeout a section of text with a horizontal line, begin and end it
397with `~~`. Thus, for example,
399 This ~~is deleted text.~~
401Lists
402-----
404Pandoc behaves differently from standard markdown on some "edge
405cases" involving lists. Consider this source:
407 1. First
408 2. Second:
409 - Fee
410 - Fie
411 - Foe
413 3. Third
415Pandoc transforms this into a "compact list" (with no `<p>` tags
416around "First", "Second", or "Third"), while markdown puts `<p>`
417tags around "Second" and "Third" (but not "First"), because of
418the blank space around "Third". Pandoc follows a simple rule:
419if the text is followed by a blank line, it is treated as a
420paragraph. Since "Second" is followed by a list, and not a blank
421line, it isn't treated as a paragraph. The fact that the list
422is followed by a blank line is irrelevant. (Note: Pandoc works
423this way even when the `--strict` option is specified. This
424behavior is consistent with the official markdown syntax
425description, even though it is different from that of `Markdown.pl`.)
427Unlike standard markdown, Pandoc allows ordered list items to be
428marked with single lowercase letters (from 'a' to 'n'), instead of
429numbers. So, for example, this source yields a nested ordered list:
431 1. First
432 2. Second
433 a. Fee
434 b. Fie
435 3. Third
437The letters may be followed by either '.' or ')':
439 1. First
440 2. Second
441 a) Fee
442 b) Fie
443 3. Third
445Note that Pandoc pays no attention to the *type* of ordered list
446item marker used. Thus, the following is treated just the same as
447the example above:
449 a) First
450 1. Second
451 2. Fee
452 b) Fie
453 c. Third
455Definition lists
456----------------
458Pandoc supports definition lists, using a syntax inspired by
459[PHP Markdown Extra] and [reStructuredText]:
461 [PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
463 Term 1
464 : Definition 1
466 Term 2
467 : Definition 2
469 : Second paragraph of definition 2.
471Each term must fit on one line. The definition must begin on the line
472after the term. The definition consists of one or more block elements
473(paragraph, code block, list, etc.), each beginning with a colon and
474(aside from the colon) indented one tab stop.
476 Term *with inline markup*
477 : Here is the definition. It may
478 contain multiple blocks. Here is some code:
480 : {* my code *}
482 : Here is the third paragraph of this definition.
484If you leave space after the definition (as in the first example above),
485the definitions will be considered paragraphs. In some output formats,
486this will mean greater spacing between term/definition pairs. For a
487compact definition list, do not leave space between the definition and
488the next term:
490 Term 1
491 : Definition 1
492 Term 2
493 : Definition 2
495Reference links
496---------------
498Pandoc allows implicit reference links with just a single set of
499brackets. So, the following links are equivalent:
501 1. Here's my [link]
502 2. Here's my [link][]
504 [link]: linky.com
506(Note: Pandoc works this way even if `--strict` is specified, because
507`Markdown.pl` 1.0.2b7 allows single-bracket links.)
509Footnotes
510---------
512Pandoc's markdown allows footnotes, using the following syntax:
514 Here is a footnote reference,[^1] and another.[^longnote]
516 [^1]: Here is the footnote. It can go anywhere in the document,
517 except in embedded contexts like block quotes or lists.
519 [^longnote]: Here's the other note. This one contains multiple
520 blocks.
522 Subsequent paragraphs are indented to show that they belong to
523 the previous footnote.
525 { some.code }
527 The whole paragraph can be indented, or just the first line.
528 In this way, multi-paragraph footnotes work just like
529 multi-paragraph list items in markdown.
531 This paragraph won't be part of the note, because it isn't indented.
533The identifiers in footnote references may not contain spaces, tabs,
534or newlines. These identifiers are used only to correlate the
535footnote reference with the note itself; in the output, footnotes
536will be numbered sequentially.
538The footnotes themselves need not be placed at the end of the
539document. They may appear anywhere except inside other block elements
540(lists, block quotes, tables, etc.).
542Inline footnotes are also allowed (though, unlike regular notes,
543they cannot contain multiple paragraphs). The syntax is as follows:
545 Here is an inline note.^[Inlines notes are easier to write, since
546 you don't have to pick an identifier and move down to type the
547 note.]
549Inline and regular footnotes may be mixed freely.
551Tables
552------
554Two kinds of tables may be used. Both kinds presuppose the use of
555a fixed-width font, such as Courier.
557Simple tables look like this:
559 Right Left Center Default
560 ------- ------ ---------- -------
561 12 12 12 12
562 123 123 123 123
563 1 1 1 1
565 Table: Demonstration of simple table syntax.
567The headers and table rows must each fit on one line. Column
568alignments are determined by the position of the header text relative
569to the dashed line below it:[^1]
571 - If the dashed line is flush with the header text on the right side
572 but extends beyond it on the left, the column is right-aligned.
573 - If the dashed line is flush with the header text on the left side
574 but extends beyond it on the right, the column is left-aligned.
575 - If the dashed line extends beyond the header text on both sides,
576 the column is centered.
577 - If the dashed line is flush with the header text on both sides,
578 the default alignment is used (in most cases, this will be left).
580[^1]: This scheme is due to Michel Fortin, who proposed it on the
581 Markdown discussion list: <http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html>
583The table must end with a blank line. Optionally, a caption may be
584provided (as illustrated in the example above). A caption is a paragraph
585beginning with the string `Table:`, which will be stripped off.
587The table parser pays attention to the widths of the columns, and
588the writers try to reproduce these relative widths in the output.
589So, if you find that one of the columns is too narrow in the output,
590try widening it in the markdown source.
592Multiline tables allow headers and table rows to span multiple lines
593of text. Here is an example:
595 ---------------------------------------------------------------
596 Centered Left Right
597 Header Aligned Aligned Default aligned
598 ---------- --------- ----------- ---------------------------
599 First row 12.0 Example of a row that spans
600 multiple lines.
602 Second row 5.0 Here's another one. Note
603 the blank line between rows.
604 ---------------------------------------------------------------
606 Table: Optional caption. This, too, may span multiple
607 lines.
609These work like simple tables, but with the following differences:
611 - They must begin with a row of dashes, before the header text.
612 - They must end with a row of dashes, then a blank line.
613 - The rows must be separated by blank lines.
615Title blocks
616------------
618If the file begins with a title block
620 % title
621 % author(s) (separated by commas)
622 % date
624it will be parsed as bibliographic information, not regular text. (It
625will be used, for example, in the title of standalone LaTeX or HTML
626output.) The block may contain just a title, a title and an author,
627or all three lines. Each must begin with a % and fit on one line.
628The title may contain standard inline formatting. If you want to
629include an author but no title, or a title and a date but no author,
630you need a blank line:
632 % My title
633 %
634 % June 15, 2006
636Titles will be written only when the `--standalone` (`-s`) option is
637chosen. In HTML output, titles will appear twice: once in the
638document head -- this is the title that will appear at the top of the
639window in a browser -- and once at the beginning of the document body.
640The title in the document head can have an optional prefix attached
641(`--title-prefix` or `-T` option). The title in the body appears as
642an H1 element with class "title", so it can be suppressed or
643reformatted with CSS. If a title prefix is specified with `-T` and no
644title block appears in the document, the title prefix will be used by
645itself as the HTML title.
647The man page writer extracts a title, man page section number, and
648other header and footer information from the title line. These should
649be separated by pipe characters (`|`), as follows:
651 % title | section number (1-9) | footer left | header center
653For example,
655 % pandoc | 1 | Pandoc User Manuals | Version 4.0
657The middle of the man page footer is used for the date.
659Markdown in HTML blocks
660-----------------------
662While standard markdown leaves HTML blocks exactly as they are, Pandoc
663treats text between HTML tags as markdown. Thus, for example, Pandoc
664will turn
666 <table>
667 <tr>
668 <td>*one*</td>
669 <td>[a link](http://google.com)</td>
670 </tr>
671 </table>
673into
675 <table>
676 <tr>
677 <td><em>one</em></td>
678 <td><a href="http://google.com">a link</a></td>
679 </tr>
680 </table>
682whereas `Markdown.pl` will preserve it as is.
684There is one exception to this rule: text between `<script>` and
685`</script>` tags is not interpreted as markdown.
687This departure from standard markdown should make it easier to mix
688markdown with HTML block elements. For example, one can surround
689a block of markdown text with `<div>` tags without preventing it
690from being interpreted as markdown.
692Header identifiers in HTML
693--------------------------
695Each header element in pandoc's HTML output is given a unique
696identifier. This identifier is based on the text of the header. To
697derive the identifier from the header text,
699 - Remove all formatting, links, etc.
700 - Remove all punctuation, except dashes and hyphens.
701 - Replace all spaces, dashes, newlines, and hyphens with hyphens.
702 - Convert all alphabetic characters to lowercase.
704Thus,
706 Header text Identifier
707 --------------------------------- --- --------------------------------
708 Header identifiers in HTML → `header-identifiers-in-html`
709 *Dogs*?--in *my* house? → `dogs--in-my-house`
710 [HTML], [S5], or [RTF]? → `html-s5-or-rtf`
712These rules should, in most cases, allow one to determine the identifier
713from the header text. The exception is when several headers have the
714same text; in this case, the first will get an identifier as described
715above; the second will get the same identifier with `-1` appended; the
716third with `-2`; and so on.
718These identifiers are used to provide link targets in the table of
719contents generated by the `--toc|--table-of-contents` option. They
720also make it easy to provide links from one section of a document to
721another. A link to this section, for example, might look like this:
723 See the section on [header identifiers](#header-identifiers-in-html).
725Note, however, that this method of providing links to sections works
726only in HTML.
728Box-style blockquotes
729---------------------
731Pandoc supports emacs-style boxquote block quotes, in addition to
732standard markdown (email-style) block quotes:
734 ,----
735 | They look like this.
736 `----
738Blank lines before headers and blockquotes
739------------------------------------------
741Standard markdown syntax does not require a blank line before a header
742or blockquote. Pandoc does require this (except, of course, at the
743beginning of the document). The reason for the requirement is that
744it is all too easy for a `>` or `#` to end up at the beginning of a
745line by accident (perhaps through line wrapping). Consider, for
746example:
748 I like several of their flavors of ice cream: #22, for example, and
749 #5.
751Inline LaTeX
752------------
754Anything between two $ characters will be parsed as LaTeX math. The
755opening $ must have a character immediately to its right, while the
756closing $ must have a character immediately to its left. Thus,
757`$20,000 and $30,000` won't parse as math. The $ character can be
758escaped with a backslash if needed.
760If you pass the `-m` (`--asciimathml`) option to `pandoc`, it will
761embed the [ASCIIMathML] script in the resulting HTML. This will
762cause LaTeX math to be displayed as formulas in better
763browsers.[^2]
765[ASCIIMathML]: http://www1.chapman.edu/~jipsen/asciimath.html
767Inline LaTeX commands will also be preserved and passed unchanged
768to the LaTeX writer. Thus, for example, you can use LaTeX to
769include BibTeX citations:
771 This result was proved in \cite{jones.1967}.
773You can also use LaTeX environments. For example,
775 \begin{tabular}{|l|l|}\hline
776 Age & Frequency \\ \hline
777 18--25 & 15 \\
778 26--35 & 33 \\
779 36--45 & 22 \\ \hline
780 \end{tabular}
782Note, however, that material between the begin and end tags will
783be interpreted as raw LaTeX, not as markdown.
785[^2]: If you are serving several pages that use ASCIIMathML, it will be
786 more efficient to link to an external copy of `ASCIIMathML.js`
787 instead of using the `-m|--asciimathml` option to embed it directly
788 in web pages. To do this, get a copy of `ASCIIMathML.js` from the
789 [ASCIIMathML] website and make it available on your webserver. Then
790 create a custom header for your web page that includes the line
792 <script src=/path/to/ASCIIMathML.js></script>
794Custom headers
795==============
797When run with the "standalone" option (`-s`), `pandoc` creates a
798standalone file, complete with an appropriate header. To see the
799default headers used for html and latex, use the following commands:
801 pandoc -D html
803 pandoc -D latex
805If you want to use a different header, just create a file containing
806it and specify it on the command line as follows:
808 pandoc --header=MyHeaderFile
810Producing S5 with Pandoc
811========================
813Producing an [S5] web-based slide show with Pandoc is easy. A title
814page is constructed automatically from the document's title block (see
815above). Each section (with a level-one header) produces a single slide.
816(Note that if the section is too big, the slide will not fit on the page;
817S5 is not smart enough to produce multiple pages.)
819Here's the markdown source for a simple slide show, `eating.txt`:
821 % Eating Habits
822 % John Doe
823 % March 22, 2005
825 # In the morning
827 - Eat eggs
828 - Drink coffee
830 # In the evening
832 - Eat spaghetti
833 - Drink wine
835To produce the slide show, simply type
837 pandoc -w s5 -s eating.txt > eating.html
839and open up `eating.html` in a browser. The HTML file embeds
840all the required javascript and CSS, so no other files are necessary.
842Note that by default, the S5 writer produces lists that display
843"all at once." If you want your lists to display incrementally
844(one item at a time), use the `-i` option. If you want a
845particular list to depart from the default (that is, to display
846incrementally without the `-i` option and all at once with the
847`-i` option), put it in a block quote:
849 > - Eat spaghetti
850 > - Drink wine
852In this way incremental and nonincremental lists can be mixed in
853a single document.