インデントがあやふやなHTMLを、
$ cat test.html
<html><head><title>hello</title></head><body>world</body></html>
インデント付きに変換する。
$ html_formatter test.html
<html>
<head>
<title>hello</title>
</head>
<body>
world
</body>
</html>
ライブラリとして使う例
require "html_formatter"
puts HtmlFormatter.parse("<html><head><title>hello</title></head><body>world</body></html>")
# >> <html>
# >> <head>
# >> <title>hello</title>
# >> </head>
# >> <body>
# >> world
# >> </body>
# >> </html>
- RubyでHTMLを自動整形する - sdyuki-devel http://d.hatena.ne.jp/sdyuki/20071103/1194071945