You are not logged in.
Hello,
When using Copy as HTML in the DOM tree that Chrome's developer tools show, you get the whole thing as one single line (or a few. It is one line when copying a specific element, even if it has many nested elements inside of it). For looking at this, diffing it, and so on, it is of course way handier to have it as nicely indented HTML code instead.
I tried using tidy -i for this, but by default tidy is very strict. For example the fact that if you want to indent a sub section of an html page, there's no <html> tags is already a problem for tidy.
I tried the following way to solve the html tag problem:
tidy -xml -i file.txt
But then it sometimes outputs just a small part of the whole thing.
Basically, tidy seems not to work very well for semi-correct things that you just want to indent.
Does there exist a utility that's designed to indent any part of xml-like or html-like code into nice separate lines with indentation where possible, even if some tags might be missing or not closed or whatever? Or a command line flag of tidy that I might have missed
Thanks!
Last edited by aardwolf (2012-03-22 17:59:46)
Offline
You can try xmllint. (It's probably already installed on your system. If not, it's part of libxml2 i.e. $ pacman -S libxml2)
$ xmllint --format in.html >out.html
Offline