Command-line HTML formatter that doesn't modify HTML in any way, just indents?
I've been trying to tidy (read: HTML Tidy) 开发者_运维问答up my HTML, but it keeps trying to "fix" my HTML which actually breaks the output. I don't have time to fix all this "invalid" HTML... it renders fine in every browser, I just want to format it so that I can actually read it. Is there such a tool?
Try opening it in vim (a file editor) then use this:
gg=G
That will reindent (=
) every line from the first line (gg
) to the last (G
). It will only work if the new lines already exist. If you need to insert new lines you could add a regex to look for close tags and then insert a new line.
%s/\>/\>\\n/g
%s
whole file regex match closing tag > and replace with > new line.
If you're new to vim you can use :wq
to write (w
)[save] and quit q
精彩评论