mirror of
https://github.com/mrclay/minify.git
synced 2025-08-07 14:46:29 +02:00
Issue 58 : Minify_HTML should preserve comments containing "<!["
This commit is contained in:
@@ -68,8 +68,11 @@ class Minify_HTML {
|
||||
,array('Minify_HTML', '_removeStyleCB')
|
||||
,$html);
|
||||
|
||||
// remove HTML comments (but not IE conditional comments).
|
||||
$html = preg_replace('/<!--[^\\[][\\s\\S]*?-->/', '', $html);
|
||||
// remove HTML comments (not containing IE conditional comments).
|
||||
$html = preg_replace_callback(
|
||||
'/<!--([\\s\\S]*?)-->/'
|
||||
,array('Minify_HTML', '_commentCB')
|
||||
,$html);
|
||||
|
||||
// replace PREs with placeholders
|
||||
$html = preg_replace_callback('/\\s*(<pre\\b[^>]*?>[\\s\\S]*?<\\/pre>)\\s*/i'
|
||||
@@ -114,6 +117,13 @@ class Minify_HTML {
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected static function _commentCB($m)
|
||||
{
|
||||
return (0 === strpos($m[1], '[') || false !== strpos($m[1], '<!['))
|
||||
? $m[0]
|
||||
: '';
|
||||
}
|
||||
|
||||
protected static function _reservePlace($content)
|
||||
{
|
||||
$placeholder = '%' . self::$_replacementHash . count(self::$_placeholders) . '%';
|
||||
|
@@ -74,6 +74,7 @@ css hack {
|
||||
href="http://www.csszengarden.com/zengarden.xml" />
|
||||
</head>
|
||||
<body id="css-zen-garden">
|
||||
<!--[if !IE]>--><p>Browser != IE</p><!--<![endif]-->
|
||||
<div id="container">
|
||||
<div id="pageHeader">
|
||||
<h1><span>css Zen Garden</span></h1>
|
||||
|
@@ -20,7 +20,7 @@ rel="alternate"
|
||||
type="application/rss+xml"
|
||||
title="RSS"
|
||||
href="http://www.csszengarden.com/zengarden.xml" /></head><body
|
||||
id="css-zen-garden"><div
|
||||
id="css-zen-garden"> <!--[if !IE]>--><p>Browser != IE</p><!--<![endif]--><div
|
||||
id="container"><div
|
||||
id="pageHeader"><h1><span>css Zen Garden</span></h1><h2><span>The Beauty of <acronym
|
||||
title="Cascading Style Sheets">CSS</acronym> Design</span></h2></div><pre>
|
||||
|
@@ -72,6 +72,7 @@ css hack {
|
||||
href="http://www.csszengarden.com/zengarden.xml">
|
||||
</head>
|
||||
<body id="css-zen-garden">
|
||||
<!--[if !IE]>--><p>Browser != IE</p><!--<![endif]-->
|
||||
<div id="container">
|
||||
<div id="pageHeader">
|
||||
<h1><span>css Zen Garden</span></h1>
|
||||
|
@@ -20,7 +20,7 @@ rel="alternate"
|
||||
type="application/rss+xml"
|
||||
title="RSS"
|
||||
href="http://www.csszengarden.com/zengarden.xml"></head><body
|
||||
id="css-zen-garden"><div
|
||||
id="css-zen-garden"> <!--[if !IE]>--><p>Browser != IE</p><!--<![endif]--><div
|
||||
id="container"><div
|
||||
id="pageHeader"><h1><span>css Zen Garden</span></h1><h2><span>The Beauty of <acronym
|
||||
title="Cascading Style Sheets">CSS</acronym> Design</span></h2></div><pre>
|
||||
|
Reference in New Issue
Block a user