views:

37

answers:

2

Is there any open source HTML/XHTML source code beautifiers written in PHP?

By beautifier I mean library that correct white space indents and improve code readability and can be integrated with CMS.

+2  A: 

Use Tidy, i use it for our Drupal Application, among Others:

http://php.net/manual/en/book.tidy.php

Hannes
+1  A: 
    $dom = new DOMDocument;
    $dom -> formatOutput = true;
    $dom -> substituteEntities = false;
    $dom -> recover = true;
    $dom -> strictErrorChecking = false;
    $dom -> loadHTML ( $file);
    echo $dom -> saveHTML ( $file);
stillstanding
I found DOMDocument very fragile when content is not 100% UTF-8 and all special characters are not escaped properly.
Nazariy