Pretty Print HTML in Ruby (or Shell)
XML files
xmllint --format file.xml
HTML files
xmllint --format --html file.html
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/xmllint.1.html
In shells, another option is to use pup without arguments:
pup
XmlStarlet also supports using an HTML parser. fo
is short for format
. See xml fo -h
for help.
xml fo --html
The main implementation of tidy
does not support HTML5 but tidy-html5 does. brew install tidy-html5
installs tidy-html5
as /usr/local/bin/tidy
in OS X.