TidyLib is a library for cleaning up and pretty printing HTML, XHTML and XML
markup in a variety of file encodings. For HTML variants, it can detect and
report proprietary elements as well as many common coding errors, correct them
and produce visually equivalent markup which is both compliant with W3C
standards and works on most browsers. Furthermore, it can convert plain HTML
into XHTML. For generic XML files, Tidy is limited to correcting basic
well-formedness errors and pretty printing.
There is a commandline frontend for this library, contained in the package
"tidy".