git.iko.soy/typeable/pandoc
on a6da87f help sign in
915 lines 33 kB history raw
1% Pandoc User's Guide
2% John MacFarlane
3% August 15, 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© 2006-7 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`
62 + `fancyhdr` (if you have verbatim text in footnotes)
63 + `graphicx` (if you use images)
64 + `array` (if you use tables)
65 + `ulem` (if you use 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 ch1.txt ch2.txt refs.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, option lists, or footnotes. But for simple documents it
113should be adequate. The `latex` and `html` readers are also limited in
114what they can do. Because the `html` reader is picky about the HTML it
115parses, it is recommended that you pipe HTML through [HTML Tidy] before
116sending it to `pandoc`, or use the `html2markdown` script described
117below.
119If you don't specify a reader or writer explicitly, `pandoc` will
120try to determine the input and output format from the extensions of
121the input and output filenames. Thus, for example,
123 pandoc -o hello.tex hello.txt
125will convert `hello.txt` from markdown to LaTeX. If no output file
126is specified (so that output goes to STDOUT), or if the output file's
127extension is unknown, the output format will default to HTML.
128If no input file is specified (so that input comes from STDIN), or
129if the input files' extensions are unknown, the input format will
130be assumed to be markdown unless explicitly specified.
132Character encodings
133-------------------
135All input is assumed to be in the UTF-8 encoding, and all output
136is in UTF-8. If your local character encoding is not UTF-8 and you use
137accented or foreign characters, you should pipe the input and output
138through [`iconv`]. For example,
140 iconv -t utf-8 source.txt | pandoc | iconv -f utf-8 > output.html
142will convert `source.txt` from the local encoding to UTF-8, then
143convert it to HTML, then convert back to the local encoding,
144putting the output in `output.html`.
146The shell scripts (described below) automatically convert the input
147from the local encoding to UTF-8 before running them through `pandoc`,
148then convert the output back to the local encoding.
150Shell scripts
151=============
153Three shell scripts, `markdown2pdf`, `html2markdown`, and `hsmarkdown`,
154are included in the standard Pandoc installation. (They are not included
155in the Windows binary package, as they require a POSIX shell, but they
156may be used in Windows under Cygwin.)
1581. `markdown2pdf` produces a PDF file from markdown-formatted
159 text, using `pandoc` and `pdflatex`. The default
160 behavior of `markdown2pdf` is to create a file with the same
161 base name as the first argument and the extension `pdf`; thus,
162 for example,
164 markdown2pdf sample.txt endnotes.txt
166 will produce `sample.pdf`. (If `sample.pdf` exists already,
167 it will be backed up before being overwritten.) An output file
168 name can be specified explicitly using the `-o` option:
170 markdown2pdf -o book.pdf chap1 chap2
172 If no input file is specified, input will be taken from STDIN.
173 All of `pandoc`'s options will work with `markdown2pdf` as well.
1752. `html2markdown` grabs a web page from a file or URL and converts
176 it to markdown-formatted text, using `tidy` and `pandoc`.
178 All of `pandoc`'s options will work with `html2markdown` as well.
179 In addition, the following special options may be used.
180 The special options must be separated from the `html2markdown`
181 command and any regular Pandoc options by the delimiter `--`:
183 html2markdown -o out.txt -- -e latin1 -g curl google.com
185 The `-e` or `--encoding` option specifies the character encoding
186 of the HTML input. If this option is not specified, and input
187 is not from STDIN, `html2markdown` will attempt to determine the
188 page's character encoding from the "Content-type" meta tag.
189 If this is not present, UTF-8 is assumed.
191 The `-g` or `--grabber` option specifies the command to be used to
192 fetch the contents of a URL:
194 html2markdown -g 'curl --user foo:bar' www.mysite.com
196 If this option is not specified, `html2markdown` searches for an
197 available program (`wget`, `curl`, or a text-mode browser) to fetch
198 the contents of a URL.
2003. `hsmarkdown` is designed to be used as a drop-in replacement for
201 `Markdown.pl`. It forces `pandoc` to convert from markdown to
202 HTML, and to use the `--strict` flag for maximal compliance with
203 official markdown syntax. (All of Pandoc's syntax extensions and
204 variants, described below, are disabled.) No other command-line
205 options are allowed. (In fact, options will be interpreted as
206 filenames.)
208 As an alternative to using the `hsmarkdown` shell script, the
209 user may create a symbolic link to `pandoc` called `hsmarkdown`.
210 When invoked under the name `hsmarkdown`, `pandoc` will behave
211 as if the `--strict` flag had been selected, and no command-line
212 options will be recognized. However, this approach does not work
213 under Cygwin, due to problems with its simulation of symbolic
214 links.
216Command-line options
217====================
219Various command-line options can be used to customize the output.
220For further documentation, see the `pandoc(1)` man page.
222`-f`, `--from`, `-r`, or `--read` *format*
223: specifies the input format (the format Pandoc will be converting
224 *from*). *format* can be `native`, `markdown`, `rst`, `html`, or
225 `latex`.
227`-t`, `--to`, `-w`, or `--write` *format*
228: specifies the output format -- the format Pandoc will
229 be converting *to*. *format* can be `native`, `html`, `s5`,
230 `docbook`, `latex`, `context`, `markdown`, `man`, `rst`, and `rtf`.
232`-s` or `--standalone`
233: indicates that a standalone document is to be produced (with
234 appropriate headers and footers), rather than a fragment.
236`-o` or `--output` *filename*
237: sends output to *filename*. If this option is not specified,
238 or if its argument is `-`, output will be sent to STDOUT.
240`-p` or `--preserve-tabs`
241: causes tabs in the source text to be preserved, rather than converted
242 to spaces (the default).
244`--tabstop` *tabstop*
245: sets the number of spaces per tab to *tabstop* (defaults to 4).
247`--strict`
248: specifies that strict markdown syntax is to be used, without
249 pandoc's usual extensions and variants (described below). When the
250 input format is HTML, this means that constructs that have no
251 equivalents in standard markdown (e.g. definition lists or strikeout
252 text) will be parsed as raw HTML.
254`--reference-links`
255: causes reference-style links to be used in markdown
256 and reStructuredText output. By default inline links are used.
258`-R` or `--parse-raw`
259: causes the HTML and LaTeX readers to parse HTML codes and LaTeX
260 environments that it can't translate as raw HTML or LaTeX. Raw HTML can
261 be printed in markdown, reStructuredText, HTML, and S5 output; raw LaTeX
262 can be printed in markdown, reStructuredText, LaTeX, and ConTeXt output.
263 The default is for the readers to omit untranslatable HTML codes and
264 LaTeX environments. (The LaTeX reader does pass through untranslatable
265 LaTeX *commands*, even if `-R` is not specified.)
267`-C` or `--custom-header` *filename*
268: can be used to specify a custom document header. To see the headers
269 used by default, use the `-D` option: for example, `pandoc -D html`
270 prints the default HTML header.
272`--toc` or `--table-of-contents`
273: includes an automatically generated table of contents (or, in the
274 case of `latex`, `context`, and `rst`, an instruction to create
275 one) in the output document. This option has no effect with `man`,
276 `docbook`, or `s5` output formats.
278`-c` or `--css` *filename*
279: allows the user to specify a custom stylesheet that will be linked to
280 in HTML and S5 output.
282`-H` or `--include-in-header` *filename*
283: includes the contents of *filename* (verbatim) at the end of the
284 document header. This can be used, for example, to include special
285 CSS or javascript in HTML documents.
287`-B` or `--include-before-body` *filename*
288: includes the contents of *filename* (verbatim) at the beginning of
289 the document body (e.g. after the `<body>` tag in HTML, or the
290 `\begin{document}` command in LaTeX). This can be used to include
291 navigation bars or banners in HTML documents.
293`-A` or `--include-after-body` *filename*
294: includes the contents of *filename* (verbatim) at the end of
295 the document body (before the `</body>` tag in HTML, or the
296 `\end{document}` command in LaTeX).
298`-T` or `--title-prefix` *string*
299: includes *string* as a prefix at the beginning of the title that
300 appears in the HTML header (but not in the title as it appears at
301 the beginning of the HTML body). (See below on
302 [Title Blocks](#title-blocks).)
304`-S` or `--smart`
305: causes `pandoc` to produce typographically correct output, along the
306 lines of John Gruber's [Smartypants]. Straight quotes are converted
307 to curly quotes, `---` to dashes, and `...` to ellipses. (Note: This
308 option is only significant when the input format is `markdown`.
309 It is selected automatically when the output format is `latex` or
310 `context`.)
312`-m`*[url]* or `--asciimathml`*[=url]*
313: will cause LaTeX formulas (between $ signs) in HTML or S5 to display
314 as formulas rather than as code. The trick will not work in all
315 browsers, but it works in Firefox. Peter Jipsen's [ASCIIMathML]
316 script is used to do the magic. If a local copy of `ASCIIMathML.js`
317 is available on the webserver where the page will be viewed,
318 provide a *url* and a link will be inserted in the generated
319 HTML or S5. If no *url* is provided, the contents of the script
320 will be inserted directly; this provides portability at the price of
321 efficiency. If you plan to use math on several pages, it is much
322 better to link to a copy of `ASCIIMathML.js`, which can be cached.
324`-i` or `--incremental`
325: causes all lists in S5 output to be displayed incrementally by
326 default (one item at a time). The normal default is for lists to be
327 displayed all at once.
329`-N` or `--number-sections`
330: causes sections to be numbered in LaTeX or ConTeXt output. By default,
331 sections are not numbered.
333`--dump-args`
334: is intended to make it easier to create wrapper scripts that use
335 Pandoc. It causes Pandoc to dump information about the arguments
336 with which it was called to STDOUT, then exit. The first line
337 printed is the name of the output file specified using the `-o`
338 or `--output` option, or `-` if output would go to STDOUT. The
339 remaining lines, if any, list command-line arguments. These will
340 include the names of input files and any special options passed
341 after ` -- ` on the command line. So, for example,
343: pandoc --dump-args -o foo.html -s foo.txt \
344 appendix.txt -- -e latin1
346: will cause the following to be printed to STDOUT:
348: foo.html foo.txt appendix.txt -e latin1
350`--ignore-args`
351: causes Pandoc to ignore all command-line arguments.
352 Regular Pandoc options are not ignored. Thus, for example,
354: pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
356: is equivalent to
358: pandoc -o foo.html -s
360`-v` or `--version`
361: prints the version number to STDERR.
363`-h` or `--help`
364: prints a usage message to STDERR.
366[Smartypants]: http://daringfireball.net/projects/smartypants/
367[ASCIIMathML]: http://www1.chapman.edu/~jipsen/mathml/asciimath.html
369Pandoc's markdown vs. standard markdown
370=======================================
372In parsing markdown, Pandoc departs from and extends [standard markdown]
373in a few respects. (To run Pandoc on the official markdown test suite,
374type `make test-markdown`.) Except where noted, these differences can
375be suppressed by specifying the `--strict` command-line option or by
376using the `hsmarkdown` wrapper.
378[standard markdown]: http://daringfireball.net/projects/markdown/syntax
379 "Markdown syntax description"
381Backslash escapes
382-----------------
384Except inside a code block or inline code, any punctuation or space
385character preceded by a backslash will be treated literally, even if it
386would normally indicate formatting. Thus, for example, if one writes
388 *\*hello\**
390one will get
392 <em>*hello*</em>
394instead of
396 <strong>hello</strong>
398This rule is easier to remember than standard markdown's rule,
399which allows only the following characters to be backslash-escaped:
401 \`*_{}[]()>#+-.!
403Subscripts and superscripts
404---------------------------
406Superscripts may be written by surrounding the superscripted text by `^`
407characters; subscripts may be written by surrounding the subscripted
408text by `~` characters. Thus, for example,
410 H~2~O is a liquid. 2^10^ is 1024.
412If the superscripted or subscripted text contains spaces, these spaces
413must be escaped with backslashes. (This is to prevent accidental
414superscripting and subscripting through the ordinary use of `~` and `^`.)
415Thus, if you want the letter P with 'a cat' in subscripts, use
416`P~a\ cat~`, not `P~a cat~`.
418Strikeout
419---------
421To strikeout a section of text with a horizontal line, begin and end it
422with `~~`. Thus, for example,
424 This ~~is deleted text.~~
426Lists
427-----
429Pandoc behaves differently from standard markdown on some "edge
430cases" involving lists. Consider this source:
432 1. First
433 2. Second:
434 - Fee
435 - Fie
436 - Foe
438 3. Third
440Pandoc transforms this into a "compact list" (with no `<p>` tags around
441"First", "Second", or "Third"), while markdown puts `<p>` tags around
442"Second" and "Third" (but not "First"), because of the blank space
443around "Third". Pandoc follows a simple rule: if the text is followed by
444a blank line, it is treated as a paragraph. Since "Second" is followed
445by a list, and not a blank line, it isn't treated as a paragraph. The
446fact that the list is followed by a blank line is irrelevant. (Note:
447Pandoc works this way even when the `--strict` option is specified. This
448behavior is consistent with the official markdown syntax description,
449even though it is different from that of `Markdown.pl`.)
451Unlike standard markdown, Pandoc allows ordered list items to be marked
452with uppercase and lowercase letters and roman numerals, in addition to
453arabic numerals. (This behavior can be turned off using the `--strict`
454option.) List markers may be enclosed in parentheses or followed by a
455single right-parentheses or period. They must be separated from the
456text that follows by at least one space, and, if the list marker is a
457capital letter with a period, by at least two spaces.[^2]
459[^2]: The point of this rule is to ensure that normal paragraphs
460 starting with people's initials, like
462 B. Russell was an English philosopher.
464 do not get treated as list items.
466 This rule will not prevent
468 (C) 2007 Joe Smith
470 from being interpreted as a list item. In this case, a backslash
471 escape can be used:
473 (C\) 2007 Joe Smith
475Pandoc also pays attention to the type of list marker used, and to the
476starting number, and both of these are preserved where possible in the
477output format. Thus, the following yields a list with numbers followed
478by a single parenthesis, starting with 9, and a sublist with lowercase
479roman numerals:
481 9) Ninth
482 10) Tenth
483 11) Eleventh
484 i. subone
485 ii. subtwo
486 iii. subthree
488Note that Pandoc pays attention only to the *starting* number in a list.
489So, the following yields a list numbered sequentially starting from 2:
491 (2) Two
492 (5) Three
493 (2) Four
495If default list markers are desired, use '`#.`':
497 #. one
498 #. two
499 #. three
501If you change list style in mid-list, Pandoc will notice and assume you
502are starting a sublist. So,
504 1. One
505 2. Two
506 A. Sub
507 B. Sub
508 3. Three
510gets treated as if it were
512 1. One
513 2. Two
514 A. Sub
515 B. Sub
516 3. Three
519Definition lists
520----------------
522Pandoc supports definition lists, using a syntax inspired by
523[PHP Markdown Extra] and [reStructuredText]:
525 [PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
527 Term 1
528 : Definition 1
530 Term 2
531 : Definition 2
533 : Second paragraph of definition 2.
535Each term must fit on one line. The definition must begin on the line
536after the term. The definition consists of one or more block elements
537(paragraph, code block, list, etc.), each beginning with a colon and
538(aside from the colon) indented one tab stop.
540 Term *with inline markup*
541 : Here is the definition. It may contain multiple blocks.
542 Here is some code:
544 : {* my code *}
546 : Here is the third paragraph of this definition.
548If you leave space after the definition (as in the first example above),
549the definitions will be considered paragraphs. In some output formats,
550this will mean greater spacing between term/definition pairs. For a
551compact definition list, do not leave space between the definition and
552the next term:
554 Term 1
555 : Definition 1
556 Term 2
557 : Definition 2
559Reference links
560---------------
562Pandoc allows implicit reference links with just a single set of
563brackets. So, the following links are equivalent:
565 1. Here's my [link]
566 2. Here's my [link][]
568 [link]: linky.com
570(Note: Pandoc works this way even if `--strict` is specified, because
571`Markdown.pl` 1.0.2b7 allows single-bracket links.)
573Footnotes
574---------
576Pandoc's markdown allows footnotes, using the following syntax:
578 Here is a footnote reference,[^1] and another.[^longnote]
580 [^1]: Here is the footnote.
582 [^longnote]: Here's one with multiple blocks.
584 Subsequent paragraphs are indented to show that they
585 belong to the previous footnote.
587 { some.code }
589 The whole paragraph can be indented, or just the first
590 line. In this way, multi-paragraph footnotes work like
591 multi-paragraph list items.
593 This paragraph won't be part of the note, because it isn't indented.
595The identifiers in footnote references may not contain spaces, tabs,
596or newlines. These identifiers are used only to correlate the
597footnote reference with the note itself; in the output, footnotes
598will be numbered sequentially.
600The footnotes themselves need not be placed at the end of the
601document. They may appear anywhere except inside other block elements
602(lists, block quotes, tables, etc.).
604Inline footnotes are also allowed (though, unlike regular notes,
605they cannot contain multiple paragraphs). The syntax is as follows:
607 Here is an inline note.^[Inlines notes are easier to write, since
608 you don't have to pick an identifier and move down to type the
609 note.]
611Inline and regular footnotes may be mixed freely.
613Tables
614------
616Two kinds of tables may be used. Both kinds presuppose the use of
617a fixed-width font, such as Courier.
619Simple tables look like this:
621 Right Left Center Default
622 ------- ------ ---------- -------
623 12 12 12 12
624 123 123 123 123
625 1 1 1 1
627 Table: Demonstration of simple table syntax.
629The headers and table rows must each fit on one line. Column
630alignments are determined by the position of the header text relative
631to the dashed line below it:[^1]
633 - If the dashed line is flush with the header text on the right side
634 but extends beyond it on the left, the column is right-aligned.
635 - If the dashed line is flush with the header text on the left side
636 but extends beyond it on the right, the column is left-aligned.
637 - If the dashed line extends beyond the header text on both sides,
638 the column is centered.
639 - If the dashed line is flush with the header text on both sides,
640 the default alignment is used (in most cases, this will be left).
642[^1]: This scheme is due to Michel Fortin, who proposed it on the
643 Markdown discussion list:
644 <http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html>.
646The table must end with a blank line. Optionally, a caption may be
647provided (as illustrated in the example above). A caption is a paragraph
648beginning with the string `Table:`, which will be stripped off.
650The table parser pays attention to the widths of the columns, and
651the writers try to reproduce these relative widths in the output.
652So, if you find that one of the columns is too narrow in the output,
653try widening it in the markdown source.
655Multiline tables allow headers and table rows to span multiple lines
656of text. Here is an example:
658 -------------------------------------------------------------
659 Centered Default Right Left
660 Header Aligned Aligned Aligned
661 ----------- ------- --------------- -------------------------
662 First row 12.0 Example of a row that
663 spans multiple lines.
665 Second row 5.0 Here's another one. Note
666 the blank line between
667 rows.
668 -------------------------------------------------------------
670 Table: Here's the caption. It, too, may span
671 multiple lines.
673These work like simple tables, but with the following differences:
675 - They must begin with a row of dashes, before the header text.
676 - They must end with a row of dashes, then a blank line.
677 - The rows must be separated by blank lines.
679Title blocks
680------------
682If the file begins with a title block
684 % title
685 % author(s) (separated by commas)
686 % date
688it will be parsed as bibliographic information, not regular text. (It
689will be used, for example, in the title of standalone LaTeX or HTML
690output.) The block may contain just a title, a title and an author,
691or all three lines. Each must begin with a % and fit on one line.
692The title may contain standard inline formatting. If you want to
693include an author but no title, or a title and a date but no author,
694you need a blank line:
696 % My title
697 %
698 % June 15, 2006
700Titles will be written only when the `--standalone` (`-s`) option is
701chosen. In HTML output, titles will appear twice: once in the
702document head -- this is the title that will appear at the top of the
703window in a browser -- and once at the beginning of the document body.
704The title in the document head can have an optional prefix attached
705(`--title-prefix` or `-T` option). The title in the body appears as
706an H1 element with class "title", so it can be suppressed or
707reformatted with CSS. If a title prefix is specified with `-T` and no
708title block appears in the document, the title prefix will be used by
709itself as the HTML title.
711The man page writer extracts a title, man page section number, and
712other header and footer information from the title line. The title
713is assumed to be the first word on the title line, which may optionally
714end with a (single-digit) section number in parentheses. (There should
715be no space between the title and the parentheses.) Anything after
716this is assumed to be additional footer and header text. A single pipe
717character (`|`) should be used to separate the footer text from the header
718text. Thus,
720 % PANDOC(1)
722will yield a man page with the title `PANDOC` and section 1.
724 % PANDOC(1) Pandoc User Manuals
726will also have "Pandoc User Manuals" in the footer.
728 % PANDOC(1) Pandoc User Manuals | Version 4.0
730will also have "Version 4.0" in the header.
732Markdown in HTML blocks
733-----------------------
735While standard markdown leaves HTML blocks exactly as they are, Pandoc
736treats text between HTML tags as markdown. Thus, for example, Pandoc
737will turn
739 <table>
740 <tr>
741 <td>*one*</td>
742 <td>[a link](http://google.com)</td>
743 </tr>
744 </table>
746into
748 <table>
749 <tr>
750 <td><em>one</em></td>
751 <td><a href="http://google.com">a link</a></td>
752 </tr>
753 </table>
755whereas `Markdown.pl` will preserve it as is.
757There is one exception to this rule: text between `<script>` and
758`</script>` tags is not interpreted as markdown.
760This departure from standard markdown should make it easier to mix
761markdown with HTML block elements. For example, one can surround
762a block of markdown text with `<div>` tags without preventing it
763from being interpreted as markdown.
765Header identifiers in HTML
766--------------------------
768Each header element in pandoc's HTML output is given a unique
769identifier. This identifier is based on the text of the header. To
770derive the identifier from the header text,
772 - Remove all formatting, links, etc.
773 - Remove all punctuation, except dashes and hyphens.
774 - Replace all spaces, dashes, newlines, and hyphens with hyphens.
775 - Convert all alphabetic characters to lowercase.
777Thus, for example, a heading 'Header identifiers in HTML' will get
778the identifier `header-identifiers-in-html`, a heading
779'*Dogs*?--in *my* house?' will get the identifier `dogs--in-my-house`,
780and a heading '[HTML], [S5], or [RTF]?' will get the identifier
781`html-s5-or-rtf`.
783These rules should, in most cases, allow one to determine the identifier
784from the header text. The exception is when several headers have the
785same text; in this case, the first will get an identifier as described
786above; the second will get the same identifier with `-1` appended; the
787third with `-2`; and so on.
789These identifiers are used to provide link targets in the table of
790contents generated by the `--toc|--table-of-contents` option. They
791also make it easy to provide links from one section of a document to
792another. A link to this section, for example, might look like this:
794 See the section on [header identifiers](#header-identifiers-in-html).
796Note, however, that this method of providing links to sections works
797only in HTML.
799Box-style blockquotes
800---------------------
802Pandoc supports emacs-style boxquote block quotes, in addition to
803standard markdown (email-style) block quotes:
805 ,----
806 | They look like this.
807 `----
809Blank lines before headers and blockquotes
810------------------------------------------
812Standard markdown syntax does not require a blank line before a header
813or blockquote. Pandoc does require this (except, of course, at the
814beginning of the document). The reason for the requirement is that
815it is all too easy for a `>` or `#` to end up at the beginning of a
816line by accident (perhaps through line wrapping). Consider, for
817example:
819 I like several of their flavors of ice cream: #22, for example, and
820 #5.
822Inline LaTeX
823------------
825Anything between two $ characters will be parsed as LaTeX math. The
826opening $ must have a character immediately to its right, while the
827closing $ must have a character immediately to its left. Thus,
828`$20,000 and $30,000` won't parse as math. The $ character can be
829escaped with a backslash if needed.
831Pandoc can use the [ASCIIMathML] script to display LaTeX formulas
832in HTML (at least on better browsers). See above on the
833`-m|--asciimathml` command-line option.
835[ASCIIMathML]: http://www1.chapman.edu/~jipsen/asciimath.html
837Inline LaTeX commands will also be preserved and passed unchanged
838to the LaTeX writer. Thus, for example, you can use LaTeX to
839include BibTeX citations:
841 This result was proved in \cite{jones.1967}.
843Note that in LaTeX environments, like
845 \begin{tabular}{|l|l|}\hline
846 Age & Frequency \\ \hline
847 18--25 & 15 \\
848 26--35 & 33 \\
849 36--45 & 22 \\ \hline
850 \end{tabular}
852the material between the begin and end tags will be interpreted as raw
853LaTeX, not as markdown.
855Custom headers
856==============
858When run with the "standalone" option (`-s`), `pandoc` creates a
859standalone file, complete with an appropriate header. To see the
860default headers used for html and latex, use the following commands:
862 pandoc -D html
864 pandoc -D latex
866If you want to use a different header, just create a file containing
867it and specify it on the command line as follows:
869 pandoc --header=MyHeaderFile
871Producing S5 with Pandoc
872========================
874Producing an [S5] web-based slide show with Pandoc is easy. A title
875page is constructed automatically from the document's title block (see
876above). Each section (with a level-one header) produces a single slide.
877(Note that if the section is too big, the slide will not fit on the page;
878S5 is not smart enough to produce multiple pages.)
880Here's the markdown source for a simple slide show, `eating.txt`:
882 % Eating Habits
883 % John Doe
884 % March 22, 2005
886 # In the morning
888 - Eat eggs
889 - Drink coffee
891 # In the evening
893 - Eat spaghetti
894 - Drink wine
896To produce the slide show, simply type
898 pandoc -w s5 -s eating.txt > eating.html
900and open up `eating.html` in a browser. The HTML file embeds
901all the required javascript and CSS, so no other files are necessary.
903Note that by default, the S5 writer produces lists that display
904"all at once." If you want your lists to display incrementally
905(one item at a time), use the `-i` option. If you want a
906particular list to depart from the default (that is, to display
907incrementally without the `-i` option and all at once with the
908`-i` option), put it in a block quote:
910 > - Eat spaghetti
911 > - Drink wine
913In this way incremental and nonincremental lists can be mixed in
914a single document.