Beautify html output
I was wondering whether there is class or something similar which I can include into my PHP pages to beautify the HTML output.
Such as putting new lines in after tags and correctly indenting so that my source code isn't only one line, I know that to the browser it doesn't matter but I wish to do this.
I have heard of http://www.php.net/manual/en/book.tidy.php but am not clear on what it does开发者_如何学Go and how to implement it, i.e. I don't understand what the manual says about it.
The Tidy
extension is the way to go.
If you don't understand the documentation (OK, admittedly it's not very thorough), then the first results on Google for php tidy tutorials
look very promising:
- http://devzone.zend.com/article/761
- http://www.devshed.com/c/a/PHP/Working-with-the-Tidy-Library-in-PHP-5/
HTML purifier or HTML tidy seems to be the way to go for this, combined with this set of functions: http://www.php.net/manual/en/ref.outcontrol.php
http://htmlpurifier.org/ http://tidy.sourceforge.net/
Try Pretty Diff - http://prettydiff.com/?m=beautify&html It appears to be a more complete algorithm than Tidy.
精彩评论