From c25b8f01c560ca97ca8a9dc217b495966aaa4d7f Mon Sep 17 00:00:00 2001 From: Jano Slota Date: Mon, 5 May 2014 22:55:36 +0200 Subject: Updated minify, jQuery, MixItUp and Tooltipster --- inc/lib/minify/Minify/HTML.php | 53 ++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'inc/lib/minify/Minify/HTML.php') diff --git a/inc/lib/minify/Minify/HTML.php b/inc/lib/minify/Minify/HTML.php index e9453ffb..40f73076 100755 --- a/inc/lib/minify/Minify/HTML.php +++ b/inc/lib/minify/Minify/HTML.php @@ -1,22 +1,26 @@ */ class Minify_HTML { + /** + * @var boolean + */ + protected $_jsCleanComments = true; /** * "Minify" an HTML page @@ -27,21 +31,21 @@ class Minify_HTML { * * 'cssMinifier' : (optional) callback function to process content of STYLE * elements. - * + * * 'jsMinifier' : (optional) callback function to process content of SCRIPT * elements. Note: the type attribute is ignored. - * + * * 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If * unset, minify will sniff for an XHTML doctype. - * + * * @return string */ public static function minify($html, $options = array()) { - $min = new Minify_HTML($html, $options); + $min = new self($html, $options); return $min->process(); } - - + + /** * Create a minifier object * @@ -51,14 +55,14 @@ class Minify_HTML { * * 'cssMinifier' : (optional) callback function to process content of STYLE * elements. - * + * * 'jsMinifier' : (optional) callback function to process content of SCRIPT * elements. Note: the type attribute is ignored. - * + * + * 'jsCleanComments' : (optional) whether to remove HTML comments beginning and end of script block + * * 'xhtml' : (optional boolean) should content be treated as XHTML1.0? If * unset, minify will sniff for an XHTML doctype. - * - * @return null */ public function __construct($html, $options = array()) { @@ -72,9 +76,12 @@ class Minify_HTML { if (isset($options['jsMinifier'])) { $this->_jsMinifier = $options['jsMinifier']; } + if (isset($options['jsCleanComments'])) { + $this->_jsCleanComments = (bool)$options['jsCleanComments']; + } } - - + + /** * Minify the markeup given in the constructor * @@ -124,7 +131,7 @@ class Minify_HTML { // remove ws around block/undisplayed elements $this->_html = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body' - .'|caption|center|cite|col(?:group)?|dd|dir|div|dl|dt|fieldset|form' + .'|caption|center|col(?:group)?|dd|dir|div|dl|dt|fieldset|form' .'|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta' .'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)' .'|ul)\\b[^>]*>)/i', '$1', $this->_html); @@ -213,17 +220,19 @@ class Minify_HTML { // whitespace surrounding? preserve at least one space $ws1 = ($m[1] === '') ? '' : ' '; $ws2 = ($m[4] === '') ? '' : ' '; - + // remove HTML comments (and ending "//" if present) - $js = preg_replace('/(?:^\\s*\\s*$)/', '', $js); - + if ($this->_jsCleanComments) { + $js = preg_replace('/(?:^\\s*\\s*$)/', '', $js); + } + // remove CDATA section markers $js = $this->_removeCdata($js); // minify $minifier = $this->_jsMinifier ? $this->_jsMinifier - : 'trim'; + : 'trim'; $js = call_user_func($minifier, $js); return $this->_reservePlace($this->_needsCdata($js) -- cgit v1.3