Scroll to navigation

TAGSOUP(1) User Commands TAGSOUP(1)

NAME

tagsoup - convert nasty, ugly HTML to clean XHTML

SYNOPSIS

java -jar /usr/share/java/tagsoup.jar [ options ] [ files ]

DESCRIPTION

Rectify arbitrary HTML into clean XHTML, using a tailored description of HTML. The output will be well-formed XML, but not necessarily valid XHTML.

multiple input files should be processed into corresponding output files
specifies the encoding of input files
specifies the encoding of the output (if the encoding name begins with ``utf'', the output will not contain character entities; otherwise, all non-ASCII characters are represented as entities)
output rectified HTML rather than XML, omitting the XML declaration and any namespace declarations
output rectified HTML rather than XML (end-tags are omitted for empty elements, and no character escaping is done in script and style elements)
omit the XML declaration
output lexical features (specifically comments and any DOCTYPE declaration)
suppress namespaces in output
suppress unknown non-HTML elements in output
suppress default attribute values
change explicit colons in element and attribute names to underscores
don't restart any restartable elements
pass through ignorable whitespace (whitespace in element-only content) via SAX method handler ignorableWhitespace
treat unknown non-HTML elements as allowing any content (default)
treat unknown non-HTML elements as empty elements
don't allow unknown non-HTML elements to be root elements
force DOCTYPE declaration to be output with specified system identifier
force DOCTYPE declaration to be output with specified public identifier
specify standalone pseudo-attribute in output XML declaration
specify version pseudo-attribute in output XML declaration (does not affect actual version of XML output)
treat the CDATA-content elements script and style as ordinary elements (mostly for testing)
output PYX format rather than XML (mostly for testing)
input is PYX-format HTML (mostly for testing)
reuse the same Parser object internally (for testing only)
output basic help
output version number

TagSoup is a parser and reformatter for nasty, ugly HTML. Its normal processing mode is to accept HTML files on the command line, or from the standard input if none are given, and output them as clean XML to the standard output. The encoding is assumed to be the platform-local encoding on input, and is always UTF-8 on output.

When the --files option is given, each input file is processed into an output file of the corresponding name, with the extension changed to xhtml. If the extension is already xhtml, it is changed to xhtml_.

TagSoup will repair, by whatever means necessary, violations of XML well-formedness. In particular, it will fix up malformed attribute names and supply missing attribute-value quotation marks. More significantly, it supplies end-tags where HTML allows them to be omitted, and sometimes where it doesn't. It will even supply start-tags where necessary; for example, if a document begins with a <li> tag, TagSoup will automatically prefix it with <html><body><ul>.

BUGS

TagSoup can be fooled by missing close quotes after attribute values, and by incorrect character encodings (it does not contain an encoding guesser).

TagSoup doesn't understand namespace declarations, which are not properly part of HTML. Instead, any element or attribute name beginning foo: will be put into the artificial namespace urn:x-prefix:foo.

For the same reasons, namespace-qualified attributes like xml:space can't be returned as default values, though an explicit attribute in the xml namespace will be returned with the proper namespace URI.

AUTHOR

John Cowan <cowan@ccil.org>

COPYRIGHT

Copyright © 2002-2008 John Cowan
TagSoup is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

January 2008 TagSoup 1.2.1