Clean up HTML with Tidy


/ Published in: PHP
Save to your folder(s)

Cleans up HTML using tidy. Returns only part. Set show-body-only to false if you want full document.


Copy this code and paste it in your HTML
  1. function tidy_html($html)
  2. {
  3. $tidy_config = array(
  4. 'clean' => true,
  5. 'output-xhtml' => true,
  6. 'show-body-only' => true,
  7. 'word-2000' => true,
  8. 'show-body-only' => true,
  9. );
  10.  
  11. $tidy = new tidy();
  12. $tidy->parseString($html, $tidy_config, 'utf8');
  13. $tidy->cleanRepair();
  14. return tidy_get_output($tidy);
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.