private function CSSCompression_Trim::comments in Advanced CSS/JS Aggregation 6
Same name and namespace in other branches
- 7 advagg_css_compress/css-compressor-3.x/src/lib/Trim.inc \CSSCompression_Trim::comments()
Does a quick run through the script to remove all comments from the sheet,
Parameters
(string) css: Stylesheet to trim:
1 call to CSSCompression_Trim::comments()
- CSSCompression_Trim::trim in advagg_css_compress/
css-compressor-3.x/ src/ lib/ Trim.inc - Central trim handler
File
- advagg_css_compress/
css-compressor-3.x/ src/ lib/ Trim.inc, line 123
Class
- CSSCompression_Trim
- CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com
Code
private function comments($css) {
$pos = 0;
while (preg_match($this->rcmark, $css, $match, PREG_OFFSET_CAPTURE, $pos)) {
switch ($match[1][0]) {
// Start of comment block
case "/*":
if (preg_match($this->rendcomment, $css, $m, PREG_OFFSET_CAPTURE, $match[1][1] + 1)) {
$end = $m[0][1] - $match[1][1] + strlen($m[0][0]);
$css = substr_replace($css, '', $match[1][1], $end);
$pos = $match[0][1];
}
else {
$css = substr($css, 0, $match[1][1]);
break 2;
}
break;
// Start of string
case "\"":
if (preg_match($this->rendquote, $css, $m, PREG_OFFSET_CAPTURE, $match[1][1] + 1)) {
$pos = $m[0][1] + strlen($m[0][0]);
}
else {
break 2;
}
break;
// Start of string
case "'":
if (preg_match($this->rendsinglequote, $css, $m, PREG_OFFSET_CAPTURE, $match[1][1] + 1)) {
$pos = $m[0][1] + strlen($m[0][0]);
}
else {
break 2;
}
break;
// Should have never gotten here
default:
break 2;
}
}
return $css;
}