pandoc/man/man1/html2markdown.1.md

100 lines
3.2 KiB
Markdown
Raw Normal View History

% HTML2MARKDOWN(1) Pandoc User Manuals
% John MacFarlane and Recai Oktas
% June 30, 2007
# NAME
html2markdown - converts HTML to markdown-formatted text
# SYNOPSIS
html2markdown [*pandoc-options*] [\-- *special-options*] [*input-file* or
*URL*]
# DESCRIPTION
`html2markdown` converts *input-file* or *URL* (or text
from STDIN) from HTML to markdown-formatted plain text.
If a URL is specified, `html2markdown` uses an available program
(e.g. wget, w3m, lynx or curl) to fetch its contents. Output is sent
to STDOUT unless an output file is specified using the `-o`
option.
`html2markdown` uses the character encoding specified in the
"Content-type" meta tag. If this is not present, or if input comes
from STDIN, UTF-8 is assumed. A character encoding may be specified
explicitly using the `-e` special option.
# OPTIONS
`html2markdown` is a wrapper for `pandoc`, so all of
`pandoc`'s options may be used. See `pandoc`(1) for
a complete list. The following options are most relevant:
-s, \--standalone
: Include title, author, and date information (if present) at the
top of markdown output.
-o *FILE*, \--output=*FILE*
: Write output to *FILE* instead of STDOUT.
\--strict
: Use strict markdown syntax, with no extensions or variants.
\--reference-links
: Use reference-style links, rather than inline links, in writing markdown
or reStructuredText.
-R, \--parse-raw
: Parse untranslatable HTML codes as raw HTML.
\--no-wrap
: Disable text wrapping in output. (Default is to wrap text.)
Added optional HTML sanitization using a whitelist. When this option is specified (--sanitize-html on the command line), unsafe HTML tags will be replaced by HTML comments, and unsafe HTML attributes will be removed. This option should be especially useful for those who want to use pandoc libraries in web applications, where users will provide the input. + Main.hs: Added --sanitize-html option. + Text.Pandoc.Shared: Added stateSanitizeHTML to ParserState. + Text.Pandoc.Readers.HTML: - Added whitelists of sanitaryTags and sanitaryAttributes. - Added parsers to check these lists (and state) to see if a given tag or attribute should be counted unsafe. - Modified anyHtmlTag and anyHtmlEndTag to replace unsafe tags with comments. - Modified htmlAttribute to remove unsafe attributes. - Modified htmlScript and htmlStyle to remove these elements if unsafe. - Modified rawHtmlBlock to use anyHtmlBlockTag instead of anyHtmlTag and anyHtmlEndTag. This fixes a bug in markdown parsing, where inline tags would be included in raw HTML blocks. - Modified anyHtmlBlockTag to test for (not inline) rather than directly for block. This allows us to handle e.g. docbook in the markdown reader. - Minor tweaks in nonTitleNonHead and parseTitle. + Text.Pandoc.Readers.Markdown: - In non-strict mode use rawHtmlBlocks instead of htmlBlock. Simplified htmlBlock, since we know it's only called in strict mode. + Modified README and man pages to document new option. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1166 788f1e2b-df1e-0410-8736-df70ead52e1b
2008-01-03 21:32:32 +00:00
\--sanitize-html
: Sanitizes HTML using a whitelist. Unsafe tags are replaced by HTML
comments; unsafe attributes are omitted.
-H *FILE*, \--include-in-header=*FILE*
: Include contents of *FILE* at the end of the header. Implies
`-s`.
-B *FILE*, \--include-before-body=*FILE*
: Include contents of *FILE* at the beginning of the document body.
-A *FILE*, \--include-after-body=*FILE*
: Include contents of *FILE* at the end of the document body.
-C *FILE*, \--custom-header=*FILE*
: Use contents of *FILE*
as the document header (overriding the default header, which can be
printed using `pandoc -D markdown`). Implies `-s`.
# SPECIAL OPTIONS
In addition, the following special options may be used. The special
options must be separated from the `html2markdown` command and any
regular `pandoc` options by the delimiter \``--`', as in
html2markdown -o foo.txt -- -g 'curl -u bar:baz' -e latin1 \
www.foo.com
-e *encoding*, \--encoding=*encoding*
: Assume the character encoding *encoding* in reading HTML.
(Note: *encoding* will be passed to `iconv`; a list of
available encodings may be obtained using `iconv -l`.)
If this option is not specified and input is not from
STDIN, `html2markdown` will try to extract the character encoding
from the "Content-type" meta tag. If no character encoding is
specified in this way, or if input is from STDIN, UTF-8 will be
assumed.
-g *command*, \--grabber=*command*
: Use *command* to fetch the contents of a URL. (By default,
`html2markdown` searches for an available program or text-based
browser to fetch the contents of a URL.)
# SEE ALSO
`pandoc`(1), `iconv`(1)