Programming - - By Harry Fuecks

Tidy HTML

John Coggeshall has posted this slides from the International PHP Conference here.

At first glance Tidy may seem like nothing more than a nice tool for the pedantic. At second glance I start to think Tidy may be the biggest new piece of functionality in PHP for a long time; one we’re going to be thanking John for again and again.

Take a look at this slide for example – Tidy is smart enough to be able to extract legacy HTML “styling” tags and convert them to CSS. Perhaps that should be no surprise, because the underlying C library originally began with Dave Raggett (father of the HTML

tag, among many other things).

There’s also other nice features like the Word 2000 mode which suggest a tool written for the real world.

Where Tidy gets more exciting for PHP, IMO, is it enables conversion of HTML to a format ready for XML parsing. To an extent, that means it’s almost irrelevant what the HTML your PHP scripts spit out looks like – Tidy can convert it (see ob_tidyhandler) to XHTML and from there it can be transformed further with XSLT.

Note there’s also a tutorial on Tidy @ Zend here.

Sponsors