1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-21 16:13:00 +00:00

minify_css: minor improvements

", " -> ","
"0." -> "."
This commit is contained in:
Starbeamrainbowlabs 2020-07-28 21:46:00 +01:00
parent 54250e71db
commit 607c9f8529
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -627,7 +627,7 @@ function render_editor($editorName) {
* @param string $css_str The string of CSS to minify.
* @return string The minified CSS string.
*/
function minify_css($css_str) {
function minify_css(string $css_str) : string {
// Remove comments
$result = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', "", $css_str);
// Cut down whitespace
@ -635,10 +635,12 @@ function minify_css($css_str) {
// Remove whitespace after colons and semicolons
$result = str_replace([
" :", ": ", "; ",
" { ", " } ", "{ ", " {", "} ", " }"
" { ", " } ", "{ ", " {", "} ", " }",
", ", "0."
], [
":", ":", ";",
"{", "}", "{", "{", "}", "}"
"{", "}", "{", "{", "}", "}",
",", "."
], $result);
return $result;
}