1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-08 07:06:49 +02:00

Better fix for Issue 210

This commit is contained in:
Steve Clay
2011-06-23 19:21:45 +00:00
parent 1fed7e4ab8
commit 5002cd5fa7
7 changed files with 14 additions and 12 deletions

View File

@@ -236,14 +236,16 @@ class Minify_CSS_Compressor {
*/
protected function _fontFamilyCB($m)
{
$pieces = preg_split('@(\'[^\']+\'|"[^"]+")@', $m[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
foreach ($pieces as $i => $piece) {
// Issue 210: must not eliminate WS between words in unquoted families
$pieces = preg_split('/(\'[^\']+\'|"[^"]+")/', $m[1], null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$out = 'font-family:';
while (null !== ($piece = array_shift($pieces))) {
if ($piece[0] !== '"' && $piece[0] !== "'") {
$piece = trim(preg_replace('@\\s+@', ' ', $piece));
$piece = preg_replace('@\\s*,\\s*@', ',', $piece);
$pieces[$i] = $piece;
$piece = preg_replace('/\\s+/', ' ', $piece);
$piece = preg_replace('/\\s?,\\s?/', ',', $piece);
}
$out .= $piece;
}
return 'font-family:' . implode('', $pieces) . $m[2];
return $out . $m[2];
}
}

View File

@@ -5,7 +5,7 @@
@import url( /more.css );
body, td, th {
font-family: Verdana , "Bitstream Vera Sans" , sans-serif ;
font-family: Verdana , "Bitstream Vera Sans" , Arial Narrow, sans-serif ;
font-size : 12px;
}

View File

@@ -1,3 +1,3 @@
@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",Arial Narrow,sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
solid #0f7}div#content
h1+p{padding-top:0;margin-top:0}@media all and (min-width: 640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width: 2000px){#media-queries-2{background-color:#0f0}}

View File

@@ -6,7 +6,7 @@
@import url(/more.css);
body, td, th {
font-family: Verdana , "Bitstream Vera Sans" , sans-serif ;
font-family: Verdana , "Bitstream Vera Sans" , Arial Narrow, sans-serif ;
font-size : 12px;
}

View File

@@ -1,4 +1,4 @@
@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
@import url(/more.css);body,td,th{font-family:Verdana,"Bitstream Vera Sans",Arial Narrow,sans-serif;font-size:12px}.nav{margin-left:20%}#main-nav{background-color:red;border:1px
solid #0f7}div#content
h1+p{padding-top:0;margin-top:0}@media all and (min-width: 640px){#media-queries-1{background-color:#0f0}}@media screen and (max-width: 2000px){#media-queries-2{background-color:#0f0}}
/*! YUI Compressor style comments are preserved */

View File

@@ -16,7 +16,7 @@ function test_Minify_JS_ClosureCompiler()
window.undefined = undefined;
})(window);
";
$minExpected = "(function(a,b){a.addOne=function(c){return 1+c};a.undefined=b})(window);";
$minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);";
$minOutput = Minify_JS_ClosureCompiler::minify($src);
if (false !== strpos($minOutput, 'Error(22): Too many compiles')) {
echo "!NOTE: Too many recent calls to Closure Compiler API to test.\n";