searchturbine / phpwee-php-minifier

Open-source (BSD) PHP inline minifier functions for HTML, XHTML, HTML5, CSS 1-3 and Javascript. http://searchturbine.com/php/phpwee
Other
79 stars 46 forks source link

withspace removed for some tags example <u> #18

Closed almare closed 8 years ago

almare commented 8 years ago

In my code I used the tag in a

container. The result is now that the required whitespaces before and after the tag are removed. Maybe we can add some excluded tags that will not be optimized?

o-evin commented 8 years ago

Just in case you are still experiencing in this issue:

  1. HtmlMin.php, line 74, replace with the following: $divnodes = $xpath->query('//div|//p|//nav|//footer|//article|//script|//hr|//br|//ul|//li');
  2. HtmlMin.php, line 87, replace if statement with the following:

if($c->nodeType==3){ $skip = ["a","b","i","span","strong","strike","em", "small", "sub", "sup", "ins", "del", "mark"]; if($c->previousSibling != null && in_array(strtolower($c->previousSibling->nodeName), $skip) == false) { $c->nodeValue = ltrim($c->nodeValue); } if($c->nextSibling != null && in_array(strtolower($c->nextSibling->nodeName), $skip) == false) { $c->nodeValue = rtrim($c->nodeValue); } }

almare commented 8 years ago

Thx a lot!! This works great and should be committed