In a recent Project i have to deal with some external content which has a good quality when it comes to the content itself, but unfortunately the html markup is rather poor, so i decided to include tidy to clean it up, and out of convenience make it in a view helper:
/var/www/zend-framework/project-name/application/views/helpers/Tidy.php :
class Zend_View_Helper_Tidy extends Zend_View_Helper_Abstract
{
private $_config = array();
public function __construct(){
$this->_config["show-body-only"]=true;
$this->_config["wrap"]=0;
$this->_config["wrap-attributes"]=0;
$this->_config["preserve-entities"]=1;
$this->_config["output-xhtml"]=1;
$this->_config["new-inline-tags"]='go';
$this->_config['fix-bad-comments']='no';
$this->_config['hide-comments']='no';
$this->_config['drop-empty-paras']='yes';
}
public function tidy($html,$charset = 'utf8'){
return tidy_repair_string($html,$this->_config,$charset);
}
}
/var/www/zend-framework/project-name/application/views/scripts/output.phtml :
<?= $this->tidy($html); ?>
its an rather simple script and could probably have some version checking (tidy use variates from version to version when it comes to setting the char type so make sure which version you have installed).