Yii 1.1: tidycleanrepair

Clean and repair HTML with Tidy
1 follower

ETidyCleanRepair is wrapper of PHP Tidy's tidy_repair_string.

Tidy is a binding for the Tidy HTML clean and repair utility which allows you to not only clean and otherwise manipulate HTML documents, but also traverse the document tree. To use Tidy, you will need libtidy installed, available on the tidy homepage. In PHP 5 (our case :) ) you need only to compile using the --with-tidy option.

ETidyCleanRepair can be used as either a widget or a controller filter. If Tidy is not available, the content is returned unchanged.

Please read the comments on the source code for licencing information and to learn about the available configurations.




  • Yii 1.0 or above
  • PHP Tidy extension


  • Extract the release file under protected/extensions


As a component, inside a controller, cleaning user provided data:

$tidy = Yii::createComponent('application.extensions.tidycleanrepair.ETidyCleanRepair');
// ...
$tidied = $tidy->cleanRepair($form->attributes['myHTML']);

Clean-up of (X)HTML in a view (you could use a model attribute or variable instead of static (X)HTML):

<?php $this->beginWidget('application.extensions.tidycleanrepair.ETidyCleanRepair', 
                   array('config'=>array('output-xhtml'=>true, 'show-body-only'=>true))); ?>
   <h1>Hello world!</b><br>
<?php $this->endWidget('application.extensions.tidycleanrepair.ETidyCleanRepair'); ?>

Be the first person to leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: MetaYii
  • Category: Others
  • Votes: +2
  • Downloaded: 1,415 times
  • Created on: Nov 19, 2008
  • Last updated: May 19, 2009