Wanted
A command line HTML5 beautifier running under Linux.
Input
Garbled, ugly HTML5 code. Possibly the result of multiple templates. You don't love it, it doesn't love you.
Output
Pure beauty. The code is nicely indented, has enough line breaks, cares for it's whitespace. Rather than viewing it in a webbrowser, you would like to display the code on your website directly.
Suspects
- tidy does too much (heck, it alters my doctype!), and it doesn't work well with HTML5. Maybe there is a way to make it cooperate and not alter anything?
- vim does too little. It only indents. I want the program to add and remove line breaks, and to play with the whitespace inside of tags.
xmllint --format
– Syllabusecho '<!doctype html>'; (echo "<?xml version='1.0' ?>"; tail -n +2 < index.html) | xmllint --format - | sed -re 's/(<script[^>]*)\/>/\1><\/script>/g' | tail -n+2
. this should work with input documents with doctype on line 1 but no xml-prolog. outputs in the same style. – Syllabus