diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2013-10-16 11:27:54 +0200 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2013-10-16 11:27:54 +0200 |
commit | 3373bb1a16ef6d6a6701de5b87de9efa990454c9 (patch) | |
tree | b93ab028a6d5ee0cf22474d89b20e7e528e739ca /lib/exe/css.php | |
parent | 0ea5ced2b723ed55c3b9ef7e1071fe6d75c77f75 (diff) | |
parent | a467e020fa551217347181ffd6915c7d29e6ff59 (diff) | |
download | rpg-3373bb1a16ef6d6a6701de5b87de9efa990454c9.tar.gz rpg-3373bb1a16ef6d6a6701de5b87de9efa990454c9.tar.bz2 |
Merge remote-tracking branch 'origin/master' into phpstrict
Diffstat (limited to 'lib/exe/css.php')
-rw-r--r-- | lib/exe/css.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php index afba5fc02..6dfdf06e8 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -473,8 +473,19 @@ function css_compress($css){ $css = preg_replace('/ ?([;,{}\/]) ?/','\\1',$css); $css = preg_replace('/ ?: /',':',$css); + // number compression + $css = preg_replace('/([: ])0+(\.\d+?)0*((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2$3', $css); // "0.1em" to ".1em", "1.10em" to "1.1em" + $css = preg_replace('/([: ])\.(0)+((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/', '$1$2', $css); // ".0em" to "0" + $css = preg_replace('/([: ]0)0*(\.0*)?((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1', $css); // "0.0em" to "0" + $css = preg_replace('/([: ]\d+)(\.0*)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$3', $css); // "1.0em" to "1em" + $css = preg_replace('/([: ])0+(\d+|\d*\.\d+)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/', '$1$2$3', $css); // "001em" to "1em" + + // shorten attributes (1em 1em 1em 1em -> 1em) + $css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width|radius)):)([\w\.]+)( \2)+(?=[;\}]| !)/', '$1$2', $css); // "1em 1em 1em 1em" to "1em" + $css = preg_replace('/(?<![\w\-])((?:margin|padding|border|border-(?:width)):)([\w\.]+) ([\w\.]+) \2 \3(?=[;\}]| !)/', '$1$2 $3', $css); // "1em 2em 1em 2em" to "1em 2em" + // shorten colors - $css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3/", "#\\1\\2\\3",$css); + $css = preg_replace("/#([0-9a-fA-F]{1})\\1([0-9a-fA-F]{1})\\2([0-9a-fA-F]{1})\\3(?=[^\{]*[;\}])/", "#\\1\\2\\3", $css); return $css; } |