Using pandoc
If no input-file is specified, input is read from stdin. Otherwise, the input-files are concatenated (with a blank line between each) and used as input. Output goes to stdout by default (though output to stdout is disabled for the odt
, docx
, and epub
output formats). For output to a file, use the -o
option:
pandoc -o output.html input.txt
Instead of a file, an absolute URI may be given. In this case pandoc will fetch the content using HTTP:
pandoc -f html -t markdown http://www.fsf.org
If multiple input files are given, pandoc
will concatenate them all (with blank lines between them) before parsing.
The format of the input and output can be specified explicitly using command-line options. The input format can be specified using the -r/--read
or -f/--from
options, the output format using the -w/--write
or -t/--to
options. Thus, to convert hello.txt
from markdown to LaTeX, you could type:
pandoc -f markdown -t latex hello.txt
To convert hello.html
from html to markdown:
pandoc -f html -t markdown hello.html
Supported output formats are listed below under the -t/--to
option. Supported input formats are listed below under the -f/--from
option. Note that the rst
, textile
, latex
, and html
readers are not complete; there are some constructs that they do not parse.
If the input or output format is not specified explicitly, pandoc
will attempt to guess it from the extensions of the input and output filenames. Thus, for example,
pandoc -o hello.tex hello.txt
will convert hello.txt
from markdown to LaTeX. If no output file is specified (so that output goes to stdout), or if the output file’s extension is unknown, the output format will default to HTML. If no input file is specified (so that input comes from stdin), or if the input files’ extensions are unknown, the input format will be assumed to be markdown unless explicitly specified.
Pandoc uses the UTF-8 character encoding for both input and output. If your local character encoding is not UTF-8, you should pipe input and output through iconv
:
iconv -t utf-8 input.txt | pandoc | iconv -f utf-8