Skip to content

Commit

Permalink
Merge pull request #37 from websharks/feature/34
Browse files Browse the repository at this point in the history
Bug fix. Preserve spaces around `+`. See #34
  • Loading branch information
JasWSInc committed Aug 27, 2014
2 parents eee263d + 588f9b7 commit 9b8d9da
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions html-compressor/includes/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1550,16 +1550,17 @@ protected function compress_css($css)

if(!isset($static['replace'], $static['with'], $static['colors']))
{
$static['replace'] = array('{', '}', '!=', '|=', '^=', '$=', '*=', '~=', '=', '+', '~', ':', ';', ',', '>');
$static['replace'] = implode('|', $this->preg_quote_deep($static['replace'], '/'));

$static['replace'] = array('comments' => '/\/\*.*?\*\//s',
'line_breaks' => "/[\r\n\t]+/",
'extra_spaces' => '/ +/',
'de_spacifiables' => '/ *('.$static['replace'].') */',
'unnecessary_;s' => '/;\}/'
$de_spacifiables = array('{', '}', '!=', '|=', '^=', '$=', '*=', '~=', '=', '~', ':', ';', ',', '>');
$de_spacifiables = implode('|', $this->preg_quote_deep($de_spacifiables, '/'));

$static['replace'] = array(
'comments' => '/\/\*.*?\*\//s',
'line_breaks' => '/['."\r\n\t".']+/',
'extra_spaces' => '/ +/',
'de_spacifiables' => '/ *('.$de_spacifiables.') */',
'unnecessary_;s' => '/;\}/'
);
$static['with'] = array('', '', ' ', '$1', '}');
$static['with'] = array('', '', ' ', '${1}', '}');
$static['colors'] = '/(?P<context>[:,\h]+#)(?P<hex>[a-z0-9]{6})/i';
}
$css = preg_replace($static['replace'], $static['with'], $css);
Expand Down

0 comments on commit 9b8d9da

Please sign in to comment.