git.iko.soy/typeable/pandoc
on 91ee26d help sign in
919 lines 34 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`--no-wrap`
334: disables text-wrapping in output. By default, text is wrapped
335 appropriately for the output format.
337`--dump-args`
338: is intended to make it easier to create wrapper scripts that use
339 Pandoc. It causes Pandoc to dump information about the arguments
340 with which it was called to STDOUT, then exit. The first line
341 printed is the name of the output file specified using the `-o`
342 or `--output` option, or `-` if output would go to STDOUT. The
343 remaining lines, if any, list command-line arguments. These will
344 include the names of input files and any special options passed
345 after ` -- ` on the command line. So, for example,
347: pandoc --dump-args -o foo.html -s foo.txt \
348 appendix.txt -- -e latin1
350: will cause the following to be printed to STDOUT:
352: foo.html foo.txt appendix.txt -e latin1
354`--ignore-args`
355: causes Pandoc to ignore all command-line arguments.
356 Regular Pandoc options are not ignored. Thus, for example,
358: pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
360: is equivalent to
362: pandoc -o foo.html -s
364`-v` or `--version`
365: prints the version number to STDERR.
367`-h` or `--help`
368: prints a usage message to STDERR.
370[Smartypants]: http://daringfireball.net/projects/smartypants/
371[ASCIIMathML]: http://www1.chapman.edu/~jipsen/mathml/asciimath.html
373Pandoc's markdown vs. standard markdown
374=======================================
376In parsing markdown, Pandoc departs from and extends [standard markdown]
377in a few respects. (To run Pandoc on the official markdown test suite,
378type `make test-markdown`.) Except where noted, these differences can
379be suppressed by specifying the `--strict` command-line option or by
380using the `hsmarkdown` wrapper.
382[standard markdown]: http://daringfireball.net/projects/markdown/syntax
383 "Markdown syntax description"
385Backslash escapes
386-----------------
388Except inside a code block or inline code, any punctuation or space
389character preceded by a backslash will be treated literally, even if it
390would normally indicate formatting. Thus, for example, if one writes
392 *\*hello\**
394one will get
396 <em>*hello*</em>
398instead of
400 <strong>hello</strong>
402This rule is easier to remember than standard markdown's rule,
403which allows only the following characters to be backslash-escaped:
405 \`*_{}[]()>#+-.!
407Subscripts and superscripts
408---------------------------
410Superscripts may be written by surrounding the superscripted text by `^`
411characters; subscripts may be written by surrounding the subscripted
412text by `~` characters. Thus, for example,
414 H~2~O is a liquid. 2^10^ is 1024.
416If the superscripted or subscripted text contains spaces, these spaces
417must be escaped with backslashes. (This is to prevent accidental
418superscripting and subscripting through the ordinary use of `~` and `^`.)
419Thus, if you want the letter P with 'a cat' in subscripts, use
420`P~a\ cat~`, not `P~a cat~`.
422Strikeout
423---------
425To strikeout a section of text with a horizontal line, begin and end it
426with `~~`. Thus, for example,
428 This ~~is deleted text.~~
430Lists
431-----
433Pandoc behaves differently from standard markdown on some "edge
434cases" involving lists. Consider this source:
436 1. First
437 2. Second:
438 - Fee
439 - Fie
440 - Foe
442 3. Third
444Pandoc transforms this into a "compact list" (with no `<p>` tags around
445"First", "Second", or "Third"), while markdown puts `<p>` tags around
446"Second" and "Third" (but not "First"), because of the blank space
447around "Third". Pandoc follows a simple rule: if the text is followed by
448a blank line, it is treated as a paragraph. Since "Second" is followed
449by a list, and not a blank line, it isn't treated as a paragraph. The
450fact that the list is followed by a blank line is irrelevant. (Note:
451Pandoc works this way even when the `--strict` option is specified. This
452behavior is consistent with the official markdown syntax description,
453even though it is different from that of `Markdown.pl`.)
455Unlike standard markdown, Pandoc allows ordered list items to be marked
456with uppercase and lowercase letters and roman numerals, in addition to
457arabic numerals. (This behavior can be turned off using the `--strict`
458option.) List markers may be enclosed in parentheses or followed by a
459single right-parentheses or period. They must be separated from the
460text that follows by at least one space, and, if the list marker is a
461capital letter with a period, by at least two spaces.[^2]
463[^2]: The point of this rule is to ensure that normal paragraphs
464 starting with people's initials, like
466 B. Russell was an English philosopher.
468 do not get treated as list items.
470 This rule will not prevent
472 (C) 2007 Joe Smith
474 from being interpreted as a list item. In this case, a backslash
475 escape can be used:
477 (C\) 2007 Joe Smith
479Pandoc also pays attention to the type of list marker used, and to the
480starting number, and both of these are preserved where possible in the
481output format. Thus, the following yields a list with numbers followed
482by a single parenthesis, starting with 9, and a sublist with lowercase
483roman numerals:
485 9) Ninth
486 10) Tenth
487 11) Eleventh
488 i. subone
489 ii. subtwo
490 iii. subthree
492Note that Pandoc pays attention only to the *starting* number in a list.
493So, the following yields a list numbered sequentially starting from 2:
495 (2) Two
496 (5) Three
497 (2) Four
499If default list markers are desired, use '`#.`':
501 #. one
502 #. two
503 #. three
505If you change list style in mid-list, Pandoc will notice and assume you
506are starting a sublist. So,
508 1. One
509 2. Two
510 A. Sub
511 B. Sub
512 3. Three
514gets treated as if it were
516 1. One
517 2. Two
518 A. Sub
519 B. Sub
520 3. Three
523Definition lists
524----------------
526Pandoc supports definition lists, using a syntax inspired by
527[PHP Markdown Extra] and [reStructuredText]:
529 [PHP Markdown Extra]: http://www.michelf.com/projects/php-markdown/extra/
531 Term 1
532 : Definition 1
534 Term 2
535 : Definition 2
537 : Second paragraph of definition 2.
539Each term must fit on one line. The definition must begin on the line
540after the term. The definition consists of one or more block elements
541(paragraph, code block, list, etc.), each beginning with a colon and
542(aside from the colon) indented one tab stop.
544 Term *with inline markup*
545 : Here is the definition. It may contain multiple blocks.
546 Here is some code:
548 : {* my code *}
550 : Here is the third paragraph of this definition.
552If you leave space after the definition (as in the first example above),
553the definitions will be considered paragraphs. In some output formats,
554this will mean greater spacing between term/definition pairs. For a
555compact definition list, do not leave space between the definition and
556the next term:
558 Term 1
559 : Definition 1
560 Term 2
561 : Definition 2
563Reference links
564---------------
566Pandoc allows implicit reference links with just a single set of
567brackets. So, the following links are equivalent:
569 1. Here's my [link]
570 2. Here's my [link][]
572 [link]: linky.com
574(Note: Pandoc works this way even if `--strict` is specified, because
575`Markdown.pl` 1.0.2b7 allows single-bracket links.)
577Footnotes
578---------
580Pandoc's markdown allows footnotes, using the following syntax:
582 Here is a footnote reference,[^1] and another.[^longnote]
584 [^1]: Here is the footnote.
586 [^longnote]: Here's one with multiple blocks.
588 Subsequent paragraphs are indented to show that they
589 belong to the previous footnote.
591 { some.code }
593 The whole paragraph can be indented, or just the first
594 line. In this way, multi-paragraph footnotes work like
595 multi-paragraph list items.
597 This paragraph won't be part of the note, because it isn't indented.
599The identifiers in footnote references may not contain spaces, tabs,
600or newlines. These identifiers are used only to correlate the
601footnote reference with the note itself; in the output, footnotes
602will be numbered sequentially.
604The footnotes themselves need not be placed at the end of the
605document. They may appear anywhere except inside other block elements
606(lists, block quotes, tables, etc.).
608Inline footnotes are also allowed (though, unlike regular notes,
609they cannot contain multiple paragraphs). The syntax is as follows:
611 Here is an inline note.^[Inlines notes are easier to write, since
612 you don't have to pick an identifier and move down to type the
613 note.]
615Inline and regular footnotes may be mixed freely.
617Tables
618------
620Two kinds of tables may be used. Both kinds presuppose the use of
621a fixed-width font, such as Courier.
623Simple tables look like this:
625 Right Left Center Default
626 ------- ------ ---------- -------
627 12 12 12 12
628 123 123 123 123
629 1 1 1 1
631 Table: Demonstration of simple table syntax.
633The headers and table rows must each fit on one line. Column
634alignments are determined by the position of the header text relative
635to the dashed line below it:[^1]
637 - If the dashed line is flush with the header text on the right side
638 but extends beyond it on the left, the column is right-aligned.
639 - If the dashed line is flush with the header text on the left side
640 but extends beyond it on the right, the column is left-aligned.
641 - If the dashed line extends beyond the header text on both sides,
642 the column is centered.
643 - If the dashed line is flush with the header text on both sides,
644 the default alignment is used (in most cases, this will be left).
646[^1]: This scheme is due to Michel Fortin, who proposed it on the
647 Markdown discussion list:
648 <http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html>.
650The table must end with a blank line. Optionally, a caption may be
651provided (as illustrated in the example above). A caption is a paragraph
652beginning with the string `Table:`, which will be stripped off.
654The table parser pays attention to the widths of the columns, and
655the writers try to reproduce these relative widths in the output.
656So, if you find that one of the columns is too narrow in the output,
657try widening it in the markdown source.
659Multiline tables allow headers and table rows to span multiple lines
660of text. Here is an example:
662 -------------------------------------------------------------
663 Centered Default Right Left
664 Header Aligned Aligned Aligned
665 ----------- ------- --------------- -------------------------
666 First row 12.0 Example of a row that
667 spans multiple lines.
669 Second row 5.0 Here's another one. Note
670 the blank line between
671 rows.
672 -------------------------------------------------------------
674 Table: Here's the caption. It, too, may span
675 multiple lines.
677These work like simple tables, but with the following differences:
679 - They must begin with a row of dashes, before the header text.
680 - They must end with a row of dashes, then a blank line.
681 - The rows must be separated by blank lines.
683Title blocks
684------------
686If the file begins with a title block
688 % title
689 % author(s) (separated by commas)
690 % date
692it will be parsed as bibliographic information, not regular text. (It
693will be used, for example, in the title of standalone LaTeX or HTML
694output.) The block may contain just a title, a title and an author,
695or all three lines. Each must begin with a % and fit on one line.
696The title may contain standard inline formatting. If you want to
697include an author but no title, or a title and a date but no author,
698you need a blank line:
700 % My title
701 %
702 % June 15, 2006
704Titles will be written only when the `--standalone` (`-s`) option is
705chosen. In HTML output, titles will appear twice: once in the
706document head -- this is the title that will appear at the top of the
707window in a browser -- and once at the beginning of the document body.
708The title in the document head can have an optional prefix attached
709(`--title-prefix` or `-T` option). The title in the body appears as
710an H1 element with class "title", so it can be suppressed or
711reformatted with CSS. If a title prefix is specified with `-T` and no
712title block appears in the document, the title prefix will be used by
713itself as the HTML title.
715The man page writer extracts a title, man page section number, and
716other header and footer information from the title line. The title
717is assumed to be the first word on the title line, which may optionally
718end with a (single-digit) section number in parentheses. (There should
719be no space between the title and the parentheses.) Anything after
720this is assumed to be additional footer and header text. A single pipe
721character (`|`) should be used to separate the footer text from the header
722text. Thus,
724 % PANDOC(1)
726will yield a man page with the title `PANDOC` and section 1.
728 % PANDOC(1) Pandoc User Manuals
730will also have "Pandoc User Manuals" in the footer.
732 % PANDOC(1) Pandoc User Manuals | Version 4.0
734will also have "Version 4.0" in the header.
736Markdown in HTML blocks
737-----------------------
739While standard markdown leaves HTML blocks exactly as they are, Pandoc
740treats text between HTML tags as markdown. Thus, for example, Pandoc
741will turn
743 <table>
744 <tr>
745 <td>*one*</td>
746 <td>[a link](http://google.com)</td>
747 </tr>
748 </table>
750into
752 <table>
753 <tr>
754 <td><em>one</em></td>
755 <td><a href="http://google.com">a link</a></td>
756 </tr>
757 </table>
759whereas `Markdown.pl` will preserve it as is.
761There is one exception to this rule: text between `<script>` and
762`</script>` tags is not interpreted as markdown.
764This departure from standard markdown should make it easier to mix
765markdown with HTML block elements. For example, one can surround
766a block of markdown text with `<div>` tags without preventing it
767from being interpreted as markdown.
769Header identifiers in HTML
770--------------------------
772Each header element in pandoc's HTML output is given a unique
773identifier. This identifier is based on the text of the header. To
774derive the identifier from the header text,
776 - Remove all formatting, links, etc.
777 - Remove all punctuation, except dashes and hyphens.
778 - Replace all spaces, dashes, newlines, and hyphens with hyphens.
779 - Convert all alphabetic characters to lowercase.
781Thus, for example, a heading 'Header identifiers in HTML' will get
782the identifier `header-identifiers-in-html`, a heading
783'*Dogs*?--in *my* house?' will get the identifier `dogs--in-my-house`,
784and a heading '[HTML], [S5], or [RTF]?' will get the identifier
785`html-s5-or-rtf`.
787These rules should, in most cases, allow one to determine the identifier
788from the header text. The exception is when several headers have the
789same text; in this case, the first will get an identifier as described
790above; the second will get the same identifier with `-1` appended; the
791third with `-2`; and so on.
793These identifiers are used to provide link targets in the table of
794contents generated by the `--toc|--table-of-contents` option. They
795also make it easy to provide links from one section of a document to
796another. A link to this section, for example, might look like this:
798 See the section on [header identifiers](#header-identifiers-in-html).
800Note, however, that this method of providing links to sections works
801only in HTML.
803Box-style blockquotes
804---------------------
806Pandoc supports emacs-style boxquote block quotes, in addition to
807standard markdown (email-style) block quotes:
809 ,----
810 | They look like this.
811 `----
813Blank lines before headers and blockquotes
814------------------------------------------
816Standard markdown syntax does not require a blank line before a header
817or blockquote. Pandoc does require this (except, of course, at the
818beginning of the document). The reason for the requirement is that
819it is all too easy for a `>` or `#` to end up at the beginning of a
820line by accident (perhaps through line wrapping). Consider, for
821example:
823 I like several of their flavors of ice cream: #22, for example, and
824 #5.
826Inline LaTeX
827------------
829Anything between two $ characters will be parsed as LaTeX math. The
830opening $ must have a character immediately to its right, while the
831closing $ must have a character immediately to its left. Thus,
832`$20,000 and $30,000` won't parse as math. The $ character can be
833escaped with a backslash if needed.
835Pandoc can use the [ASCIIMathML] script to display LaTeX formulas
836in HTML (at least on better browsers). See above on the
837`-m|--asciimathml` command-line option.
839[ASCIIMathML]: http://www1.chapman.edu/~jipsen/asciimath.html
841Inline LaTeX commands will also be preserved and passed unchanged
842to the LaTeX writer. Thus, for example, you can use LaTeX to
843include BibTeX citations:
845 This result was proved in \cite{jones.1967}.
847Note that in LaTeX environments, like
849 \begin{tabular}{|l|l|}\hline
850 Age & Frequency \\ \hline
851 18--25 & 15 \\
852 26--35 & 33 \\
853 36--45 & 22 \\ \hline
854 \end{tabular}
856the material between the begin and end tags will be interpreted as raw
857LaTeX, not as markdown.
859Custom headers
860==============
862When run with the "standalone" option (`-s`), `pandoc` creates a
863standalone file, complete with an appropriate header. To see the
864default headers used for html and latex, use the following commands:
866 pandoc -D html
868 pandoc -D latex
870If you want to use a different header, just create a file containing
871it and specify it on the command line as follows:
873 pandoc --header=MyHeaderFile
875Producing S5 with Pandoc
876========================
878Producing an [S5] web-based slide show with Pandoc is easy. A title
879page is constructed automatically from the document's title block (see
880above). Each section (with a level-one header) produces a single slide.
881(Note that if the section is too big, the slide will not fit on the page;
882S5 is not smart enough to produce multiple pages.)
884Here's the markdown source for a simple slide show, `eating.txt`:
886 % Eating Habits
887 % John Doe
888 % March 22, 2005
890 # In the morning
892 - Eat eggs
893 - Drink coffee
895 # In the evening
897 - Eat spaghetti
898 - Drink wine
900To produce the slide show, simply type
902 pandoc -w s5 -s eating.txt > eating.html
904and open up `eating.html` in a browser. The HTML file embeds
905all the required javascript and CSS, so no other files are necessary.
907Note that by default, the S5 writer produces lists that display
908"all at once." If you want your lists to display incrementally
909(one item at a time), use the `-i` option. If you want a
910particular list to depart from the default (that is, to display
911incrementally without the `-i` option and all at once with the
912`-i` option), put it in a block quote:
914 > - Eat spaghetti
915 > - Drink wine
917In this way incremental and nonincremental lists can be mixed in
918a single document.