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