Exemplo n.º 1
0
  -  @link http://code.google.com/p/ganon/
  -  @license http://dev.perl.org/licenses/artistic.html Artistic License
  -->
<html>

<h1>Minified HTML:</h1>

<?php 
include_once '../ganon.php';
//PHP4 users, make sure this path is correct!
//Only keep everything between body tags, delete the rest.
$html = file_get_dom('http://m.nos.nl');
$html->select('"!DOCTYPE"', 0)->delete();
$html->select('head', 0)->delete();
$html->select('body', 0)->detach(true);
$html->select('html', 0)->detach(true);
//Minified version
HTML_Formatter::minify_html($html);
echo "{$html}\n";
?>
	
<h1>Formatted HTML:</h1>

<?php 
//Formatted version
$formatter = new HTML_Formatter(array('sort_attributes' => false, 'attributes_case' => CASE_UPPER));
$formatter->format($html);
echo "{$html}\n";
?>

</html>
Exemplo n.º 2
0
function dom_format(&$root, $options = array())
{
    $formatter = new HTML_Formatter($options);
    return $formatter->format($root);
}
 /**
  * Remove whitespace, tab, new line from input
  *
  * @param $input
  * @return mixed
  */
 protected function _compressHtml($buffer)
 {
     Zo2Factory::import('vendor.ganon.ganon');
     $dom = str_get_dom($buffer);
     HTML_Formatter::minify_html($dom);
     $buffer = (string) $dom;
     return $buffer;
 }