1
0
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:
Steve Clay
2008-10-06 14:15:26 +00:00
parent 986caa3838
commit 0fe53c9813
5 changed files with 16 additions and 4 deletions

View File

@@ -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) . '%';

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>