Reputation: 79420
Is there any way to pretty print an HTML or XML string from the command line on a mac? Trying to do this in Ruby. Any ideas? I've thought about XSLT, and about writing my own parser, but both of those are pretty involved. Looking for something already out there.
Upvotes: 3
Views: 2395
Reputation: 8923
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.
Upvotes: 1
Reputation: 1561
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
Upvotes: 4