@@ -20,7 +20,7 @@ or output format requires only adding a reader or writer.
20[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
20[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
21[S5]: http://meyerweb.com/eric/tools/s5/
21[S5]: http://meyerweb.com/eric/tools/s5/
22[HTML]: http://www.w3.org/TR/html40/
22[HTML]: http://www.w3.org/TR/html40/
23−[LaTeX]: http://www.latex-project.org/
23+[LaTeX]: http://www.latex-project.org/
24[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
24[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
25[Haskell]: http://www.haskell.org/
25[Haskell]: http://www.haskell.org/
@@ -30,9 +30,53 @@ any kind. (See COPYRIGHT for full copyright and warranty notices.)
30Recai Oktaş (roktas at debian dot org) deserves credit for the build
30Recai Oktaş (roktas at debian dot org) deserves credit for the build
31system, the debian package, and the robust wrapper scripts.
31system, the debian package, and the robust wrapper scripts.
33−[GPL]: http://www.gnu.org/copyleft/gpl.html
33+[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
38+The `pandoc` program itself does not depend on any external libraries
39+or programs. The convenience programs `markdown2html`, `markdown2latex`,
40+`markdown2rst`, `markdown2rtf`, `markdown2s5`, `html2markdown`,
41+`latex2markdown`, and `rst2markdown` are implemented as symbolic links to
44+The wrapper script `web2markdown` requires
46+ - `html2markdown` (included with Pandoc)
47+ - a POSIX-compliant shell (installed by default on all linux and unix
48+ systems, including Mac OS X, and in [Cygwin] for Windows),
50+ - `iconv` (for character encoding conversion). (If `iconv` is absent,
51+ `web2markdown` will still work, but it will treat everything as UTF-8.)
53+[Cygwin]: http://www.cygwin.com/
54+[HTML Tidy]: http://tidy.sourceforge.net/
55+[`iconv`]: http://www.gnu.org/software/libiconv/
57+The wrapper script `markdown2pdf` requires
59+ - `markdown2latex` (included with Pandoc)
60+ - a POSIX-compliant shell
61+ - `pdflatex`, which should be part of any [LaTeX] distribution
62+ - the [unicode] and [fancyvrb] LaTeX packages, which are included
63+ in many LaTeX distributions. The [unicode] package allows LaTeX to
64+ process UTF-8 characters. [fancyvrb] allows code blocks and verbatim
65+ text to be used within footnotes. If your installation of LaTeX
66+ does not include these packages, you will get an error (complaining
67+ about missing `ucs.sty` or `fancyvrb.sty`) when you try to compile
68+ a LaTeX file produced by Pandoc, or when you use the `markdown2pdf`
69+ script (described below). If this happens, install the [unicode] and
70+ [fancyvrb] packages package from [CTAN]. (Get the zip file from CTAN
71+ and unpack it into `~/texmf/tex/latex/`. You may also need to run
72+ `mktexlsr` or `texhash` before the files can be found by TeX.)
74+[CTAN]: http://www.ctan.org "Comprehensive TeX Archive Network"
75+[unicode]: http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/
76+[fancyvrb]: http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/
35−# Using Pandoc
78+Using Pandoc
37If you run `pandoc` without arguments, it will accept input from
81If you run `pandoc` without arguments, it will accept input from
38STDIN. If you run it with file names as arguments, it will take input
82STDIN. If you run it with file names as arguments, it will take input
@@ -66,10 +110,14 @@ a subset of reStructuredText syntax. For example, it doesn't handle
66tables, definition lists, option lists, or footnotes. It handles only the
110tables, definition lists, option lists, or footnotes. It handles only the
67constructs expressible in unextended markdown. But for simple documents
111constructs expressible in unextended markdown. But for simple documents
68it should be adequate. The `latex` and `html` readers are also limited
112it should be adequate. The `latex` and `html` readers are also limited
69−in what they can do.
113+in what they can do. Because the `html` reader is picky about the HTML
114+it parses, it is recommended that you pipe HTML through [HTML Tidy] before
115+sending it to `pandoc`, or use the `web2markdown` script described below.
117+By default, `pandoc` writes its output to STDOUT. If you want to
118+write to a file, use the `-o` option or shell redirection:
71−`pandoc` writes its output to STDOUT. If you want to write to a file,
120+ pandoc -o hello.html hello.txt
74 pandoc hello.txt > hello.html
122 pandoc hello.txt > hello.html
@@ -77,13 +125,14 @@ Note that you can specify multiple input files on the command line.
77`pandoc` will concatenate them all (with blank lines between them)
125`pandoc` will concatenate them all (with blank lines between them)
78before parsing:
126before parsing:
80− pandoc -s chapter1.txt chapter2.txt chapter3.txt references.txt > book.html
128+ pandoc -s chapter1.txt chapter2.txt references.txt > book.html
82(The `-s` option here tells `pandoc` to produce a standalone HTML file,
130(The `-s` option here tells `pandoc` to produce a standalone HTML file,
83with a proper header, rather than a fragment. For more details on this
131with a proper header, rather than a fragment. For more details on this
84and many other command-line options, see below.)
132and many other command-line options, see below.)
86−# Character encodings
134+Character encodings
88Unfortunately, due to limitations in GHC, `pandoc` does not automatically
137Unfortunately, due to limitations in GHC, `pandoc` does not automatically
89detect the system's local character encoding. Hence, all input and
138detect the system's local character encoding. Hence, all input and
@@ -97,92 +146,65 @@ will convert `source.txt` from the local encoding to UTF-8, then
97convert it to HTML, then convert back to the local encoding,
146convert it to HTML, then convert back to the local encoding,
98putting the output in `output.html`.
147putting the output in `output.html`.
100−[`iconv`]: http://www.gnu.org/software/libiconv/
102The shell scripts (described below) automatically convert the input
149The shell scripts (described below) automatically convert the input
103from the local encoding to UTF-8 before running them through `pandoc`,
150from the local encoding to UTF-8 before running them through `pandoc`,
104then convert the output back to the local encoding.
151then convert the output back to the local encoding.
106−## LaTeX and UTF-8
153+Convenience programs and wrapper scripts
107−
154+========================================
108−LaTeX sources produced by Pandoc use `ucs.sty`, which is included in many
109−LaTeX distributions. This allows LaTeX to process UTF-8 characters.
110−If your installation of LaTeX does not include `ucs.sty`, you will get an
111−error when you try to compile a LaTeX file produced by Pandoc, or when
112−you use the `markdown2pdf` script (described below). If this happens,
113−install the [unicode] package from [CTAN]. (Get the `unicode.zip`
114−file from CTAN, unpack it, and copy the whole `unicode` directory into
115−`~/texmf/tex/latex/`. You may also need to run `mktexlsr` or `texhash`
116−before the files can be found by TeX.)
118−[CTAN]: http://www.ctan.org
156+For convenience, eight variant programs are included with Pandoc:
119−[unicode]: http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/
157+`markdown2html` (which is equivalent to `pandoc -w html`),
158+`markdown2latex` (equivalent to `pandoc -w latex`), `markdown2rst`
159+(equivalent to `pandoc -w rst`), `markdown2rtf` (equivalent to
160+`pandoc -w rtf`), `markdown2s5` (equivalent to `pandoc -w s5`),
161+`html2markdown` (equivalent to `pandoc -r html -w markdown`),
162+`latex2markdown` (equivalent to `pandoc -r latex -w markdown`), and
163+`rst2markdown` (equivalent to `pandoc -r rst -w markdown`). These
164+programs take an appropriately restricted subset of `pandoc`'s
165+options. (Run them with the `-h` flag for a full list of allowed
121−# The shell scripts
168+Like `pandoc`, all of these programs produce fragments by default.
169+If you want to produce a standalone file, complete with a header
170+and footer appropriate to the format, use the `-s` option:
123−Five shell scripts have been included that make it easy to run
172+ markdown2latex -s sample.txt > sample.tex
124−`pandoc` without worrying about character encodings, and without
125−remembering all the command-line options:
127−- `markdown2html` converts markdown-formatted text to HTML
174+Two shell scripts have also been included:
128−- `markdown2latex` converts markdown-formatted text to LaTeX
129−- `markdown2pdf` produces a PDF file from markdown-formatted
130− text, using `pdflatex`.
131−- `html2markdown` converts HTML to markdown-formatted text
132−- `latex2markdown` converts LaTeX to markdown-formatted text
134−All of the scripts use `iconv` (if available) to convert to and from
176+1. `markdown2pdf` produces a PDF file from markdown-formatted
135−the local character encoding. All of the scripts presuppose that
177+ text, using `markdown2latex` and `pdflatex`. The default
136−`pandoc` is in the path, and some have additional requirements. (For
178+ behavior of `markdown2pdf` is to create a file with the same
137−example, `html2markdown` uses `tidy`, and `markdown2pdf` uses
179+ base name as the first argument and the extension `pdf`; thus,
138−`pdflatex`.)
180+ for example,
140−When no arguments are specified, text will be read from standard
182+ markdown2pdf sample.txt endnotes.txt
141−input. Arguments specify input files (limited to one in the case of
142−`latex2markdown` and `html2markdown`; the other scripts accept any number
143−of arguments). `html2markdown` may take a URL as argument instead of
144−a filename; in this case, `curl`, `wget`, or an available text-based
145−browser will be used to fetch the contents of the URL. (The `-n` option
146−inhibits this behavior; the `-g` option allows the user to specify a
147−custom command that will be used to fetch from a URL.)
149−With the exception of `markdown2pdf`, the scripts write to standard output.
184+ will produce `sample.pdf`. (If `sample.pdf` exists already,
150−Output can be sent to a file using shell output redirection:
185+ it will be backed up before being overwritten.) An output file
186+ name can be specified explicitly using the `-o` option:
152− latex2markdown sample.tex > sample.txt
188+ markdown2pdf -o "My Book.pdf" chap1.txt chap2.txt chap3.txt
154−The default behavior of `markdown2pdf` is to create a file with the same
190+ If no input file is specified, input will be taken from STDIN.
155−base name as the first argument and the extension `pdf`; thus, for example,
157− markdown2pdf sample.txt endnotes.txt
192+2. `web2markdown` grabs a web page from a file or URL and converts
193+ it to markdown-formatted text, using `tidy` and `html2markdown`.
194+ Unless input is from STDIN, an attempt is made to determine the
195+ character encoding of the page from the "Content-type" meta tag.
196+ If this is not present, UTF-8 is assumed. Alternatively, a character
197+ encoding may be specified explicitly using the `-e` option.
159−will produce `sample.pdf`. (If `sample.pdf` exists already, it will be
199+ `web2markdown` searches for an available program (`wget`, `curl`,
160−backed up before being overwritten.) An output file name can be specified
200+ or a text-mode browser) to fetch the contents of a URL.
161−explicitly using the `-o` option:
201+ Optionally, the `-g` command may be used to specify the command
163− markdown2pdf -o "My Book.pdf" chap1.txt chap2.txt chap3.txt
204+ web2markdown -g 'wget --user=foo --password=bar' mysite.com
165−Options specific to the scripts, like `-o`, `-g`, and `-n`, must
166−be specified *before* any command-line arguments (file names or URLs).
167−Any options specified *after* the command-line arguments will be
168−passed directly to `pandoc`. For example,
170− markdown2html tusks.txt -S -T Elephants
172−will convert `tusks.txt` to `tusks.html` using smart quotes, ellipses,
173−and dashes, with "Elephants" as the page title prefix. (For a
174−complete list of `pandoc` options, see below.) When there are no
175−command-line arguments (because input is from STDIN), `pandoc`
176−options must be preceded by ` -- `:
178− cat tusks.txt | markdown2html -- -S -T Elephants
180−The ` -- ` separator may optionally be used when there are command-line
183− markdown2html -- tusks.txt -S -T Elephants
185−# Command-line options
206+Command-line options
187Various command-line options can be used to customize the output.
209Various command-line options can be used to customize the output.
188For a complete list, type
210For a complete list, type
@@ -207,9 +229,11 @@ specified.)
207complete with appropriate document headers. By default, `pandoc`
229complete with appropriate document headers. By default, `pandoc`
208produces a fragment.
230produces a fragment.
232+`-o` or `--output-file` can be used to specify an output file.
210−`--custom-header` can be used to specify a custom document header. To
234+`-C` or `--custom-header` can be used to specify a custom document
211−see the headers used by default, use the `-D` option: for example,
235+header. To see the headers used by default, use the `-D` option:
212−`pandoc -D html` prints the default HTML header.
236+for example, `pandoc -D html` prints the default HTML header.
214`-c` or `--css` allows the user to specify a custom stylesheet that
238`-c` or `--css` allows the user to specify a custom stylesheet that
215will be linked to in HTML and S5 output.
239will be linked to in HTML and S5 output.
@@ -253,15 +277,38 @@ is for lists to be displayed all at once.
253`-N` or `--number-sections` causes sections to be numbered in LaTeX
277`-N` or `--number-sections` causes sections to be numbered in LaTeX
254output. By default, sections are not numbered.
278output. By default, sections are not numbered.
280+`-d` or `--debug` causes a debugging message to be written to STDERR.
281+The format of the message is as follows:
287+Here `OUTPUT=` is followed by the name of the output file specified
288+using `-o`, if any. If no output file was specified, `OUTPUT=`
289+will appear with nothing following it. Lines beginning `INPUT=`
290+specify input files. If there are no input files, no `INPUT=` lines
291+will be printed. The `-d` option forces output to be written to
292+STDOUT, even if an output file was specified using the `-o` option.
293+(This option is provided to make it easier to write wrappers for
296+`-v` or `--version` prints the version number to STDERR.
298+`-h` or `--help` prints a usage message to STDERR.
256−# Pandoc's markdown vs. standard markdown
300+Pandoc's markdown vs. standard markdown
301+=======================================
258In parsing markdown, Pandoc departs from and extends [standard markdown]
303In parsing markdown, Pandoc departs from and extends [standard markdown]
259in a few respects. (To run Pandoc on the official
304in a few respects. (To run Pandoc on the official
260markdown test suite, type `make test-markdown`.)
305markdown test suite, type `make test-markdown`.)
262[standard markdown]: http://daringfireball.net/projects/markdown/syntax
307[standard markdown]: http://daringfireball.net/projects/markdown/syntax
308+ "Markdown syntax description"
264−## Section Headings
310+Section Headings
266Pandoc creates an invisible anchor in front of every HTML section
313Pandoc creates an invisible anchor in front of every HTML section
267heading. The ID of this anchor is derived from the section heading
314heading. The ID of this anchor is derived from the section heading
@@ -281,7 +328,8 @@ example, just insert:
282 [Back to Aristotle](#Aristotle's_De_Anima)
329 [Back to Aristotle](#Aristotle's_De_Anima)
286Pandoc behaves differently from standard markdown on some "edge
334Pandoc behaves differently from standard markdown on some "edge
287cases" involving lists. Consider this source:
335cases" involving lists. Consider this source:
@@ -332,7 +380,8 @@ the example above:
335−## Literal quotes in titles
383+Literal quotes in titles
384+------------------------
337Standard markdown allows unescaped literal quotes in titles, as
386Standard markdown allows unescaped literal quotes in titles, as
@@ -343,7 +392,8 @@ Pandoc requires all quotes within titles to be escaped:
344 [foo]: "bar \"embedded\" baz"
393 [foo]: "bar \"embedded\" baz"
346−## Reference links
395+Reference links
348Pandoc allows implicit reference links in either of two styles:
398Pandoc allows implicit reference links in either of two styles:
@@ -357,7 +407,8 @@ will appear as regular bracketed text. Note: even `[link][]` will
357appear as `[link]` if there's no reference for `link`. If you want
407appear as `[link]` if there's no reference for `link`. If you want
358`[link][]`, use a backslash escape: `\[link]\[]`.
408`[link][]`, use a backslash escape: `\[link]\[]`.
360−## Footnotes
410+Footnotes
362Pandoc's markdown allows footnotes, using the following syntax:
413Pandoc's markdown allows footnotes, using the following syntax:
@@ -394,7 +445,8 @@ they cannot contain multiple paragraphs). The syntax is as follows:
395Inline and regular footnotes may be mixed freely.
446Inline and regular footnotes may be mixed freely.
397−## Embedded HTML
448+Embedded HTML
399Pandoc treats embedded HTML in markdown a bit differently than
451Pandoc treats embedded HTML in markdown a bit differently than
400Markdown 1.0. While Markdown 1.0 leaves HTML blocks exactly as they
452Markdown 1.0. While Markdown 1.0 leaves HTML blocks exactly as they
@@ -427,7 +479,8 @@ markdown with HTML block elements. For example, one can surround
427a block of markdown text with `<div>` tags without preventing it
479a block of markdown text with `<div>` tags without preventing it
428from being interpreted as markdown.
480from being interpreted as markdown.
430−## Title blocks
482+Title blocks
432If the file begins with a title block
485If the file begins with a title block
@@ -460,7 +513,8 @@ If a title prefix is specified with `-T` and no title block appears
460in the document, the title prefix will be used by itself as the
513in the document, the title prefix will be used by itself as the
461HTML title.
514HTML title.
463−## Box-style blockquotes
516+Box-style blockquotes
517+---------------------
465Pandoc supports emacs-style boxquote block quotes, in addition to
519Pandoc supports emacs-style boxquote block quotes, in addition to
466standard markdown (email-style) boxquotes:
520standard markdown (email-style) boxquotes:
@@ -469,7 +523,8 @@ standard markdown (email-style) boxquotes:
469 | They look like this.
523 | They look like this.
472−## Inline LaTeX
526+Inline LaTeX
474Anything between two $ characters will be parsed as LaTeX math. The
529Anything between two $ characters will be parsed as LaTeX math. The
475opening $ must have a character immediately to its right, while the
530opening $ must have a character immediately to its right, while the
@@ -501,7 +556,8 @@ You can also use LaTeX environments. For example,
501Note, however, that material between the begin and end tags will
556Note, however, that material between the begin and end tags will
502be interpreted as raw LaTeX, not as markdown.
557be interpreted as raw LaTeX, not as markdown.
504−## Custom headers
559+Custom headers
506When run with the "standalone" option (`-s`), `pandoc` creates a
562When run with the "standalone" option (`-s`), `pandoc` creates a
507standalone file, complete with an appropriate header. To see the
563standalone file, complete with an appropriate header. To see the
@@ -516,13 +572,14 @@ it and specify it on the command line as follows:
517 pandoc --header=MyHeaderFile
573 pandoc --header=MyHeaderFile
519−# Producing S5 with Pandoc
575+Producing S5 with Pandoc
576+========================
521−Producing an [S5] slide show with Pandoc is easy. A title page is
578+Producing an [S5] web-based slide show with Pandoc is easy. A title
522−constructed automatically from the document's title block (see above).
579+page is constructed automatically from the document's title block (see
523−Each section (with a level-one header) produces a single slide. (Note
580+above). Each section (with a level-one header) produces a single slide.
524−that if the section is too big, the slide will not fit on the page; S5
581+(Note that if the section is too big, the slide will not fit on the page;
525−is not smart enough to produce multiple pages.)
582+S5 is not smart enough to produce multiple pages.)
527Here's the markdown source for a simple slide show, `eating.txt`:
584Here's the markdown source for a simple slide show, `eating.txt`: