Here are some other ways tidy can be used effectively, and things to watch out for...

As a Smarty Output filter
<?php
function smarty_outputfilter_tidyrepairhtml($source, &$smarty)
{
    if(extension_loaded('tidy')) {
        tidy_parse_string($source);
        tidy_clean_repair();
        return tidy_get_output();
    }
    return $source;
}
?>