99 $full =
$dir.(substr(
$dir, -1) !=
'/' ?
'/' :
'').$url;
109 return is_file(
$name);
113 if (!isset($items[1]) && isset($items[0]))
return $items[0];
114 else return array(
'list', $delim, $items);
122 if ($importPath[0] ==
"function" && $importPath[1] ==
"url") {
127 if ($str ===
null)
return false;
132 if (substr_compare($url,
'.css', -4, 4) === 0)
return false;
136 if ($realPath ===
null)
return false;
138 if ($this->importDisabled) {
139 return array(
false,
"/* import disabled */");
143 return array(
false,
null);
148 $root =
$parser->parse(file_get_contents($realPath));
151 foreach ($root->props
as $prop) {
152 if ($prop[0] ==
"block") {
153 $prop[1]->parent = $parentBlock;
160 foreach ($root->children
as $childName => $child) {
161 if (isset($parentBlock->children[$childName])) {
162 $parentBlock->children[$childName] = array_merge(
163 $parentBlock->children[$childName],
166 $parentBlock->children[$childName] = $child;
170 $pi = pathinfo($realPath);
171 $dir = $pi[
"dirname"];
185 $this->importDir = (
array)$this->importDir;
188 foreach ($props
as $prop) {
192 $this->importDir = $oldImport;
193 $this->sourceParser = $oldSourceParser;
218 switch ($block->type) {
229 $name =
"@" . $block->name;
230 if (!empty($block->value)) {
237 $this->
throwError(
"unknown block type: $block->type\n");
248 $this->scope->children[] =
$out;
251 $block->scope = $env;
262 $parentScope->children[] = $this->scope;
266 if (count($this->scope->lines) > 0) {
268 if (!is_null($orphanSelelectors)) {
270 $orphan->lines = $this->scope->lines;
271 array_unshift($this->scope->children, $orphan);
272 $this->scope->lines =
array();
276 $this->scope = $this->scope->parent;
281 while (!empty($scope->parent)) {
282 if (!empty($scope->type) && $scope->type !=
"media") {
285 $scope = $scope->parent;
294 $this->scope->parent->children[] = $this->scope;
298 $this->scope = $this->scope->parent;
310 foreach ($this->
sortProps($block->props)
as $prop) {
326 if (strpos(
$line,
'/*') === 0) {
330 if (!in_array(
$line, $unique)) {
333 array_splice($unique, array_search(
$line, $unique), 0, $comments);
336 return array_merge($unique, $comments);
345 foreach ($props
as $prop) {
352 if (isset($prop[1][0]) && $prop[1][0] == $this->vPrefix) {
355 $other = array_merge($other, $stack);
360 $id = self::$nextImportId++;
363 $imports = array_merge($imports, $stack);
364 $other[] =
array(
"import_mixin", $id);
369 $other = array_merge($other, $stack);
374 $other = array_merge($other, $stack);
377 return array(array_merge(
$vars, $imports), $other);
379 return array_merge(
$vars, $imports, $other);
384 $compiledQueries =
array();
390 $parts[] = implode(
" ", array_slice($q, 1));
394 $parts[] =
"($q[1]: " .
397 $parts[] =
"($q[1])";
406 if (count($parts) > 0) {
407 $compiledQueries[] = implode(
" and ", $parts);
412 if (!empty($parts)) {
414 implode($this->formatter->selectorSeparator, $compiledQueries);
421 !empty($env->block->type) && $env->block->type !=
"media")
423 return $childQueries;
427 if (empty($env->block->type)) {
433 if (is_null($childQueries)) {
437 foreach ($childQueries
as $child) {
438 $out[] = array_merge($parent, $child);
447 $parts = explode(
"$&$", $tag);
449 foreach ($parts
as &$part) {
450 $part = str_replace($this->parentSelector, $replace, $part, $c);
453 $tag = implode($this->parentSelector, $parts);
460 while ($env !==
null) {
461 if (isset($env->selectors)) {
462 $selectors = $env->selectors;
477 if (is_null($parentSelectors)) {
479 foreach ($selectors
as &
$s) {
487 foreach ($parentSelectors
as $parent) {
488 foreach ($selectors
as $child) {
493 $out[] = trim($child);
495 $out[] = trim($parent .
' ' . $child);
507 foreach ($selectors
as $s) {
526 if (!empty($block->guards)) {
527 $groupPassed =
false;
528 foreach ($block->guards
as $guardGroup) {
529 foreach ($guardGroup
as $guard) {
531 $this->
zipSetArgs($block->args, $orderedArgs, $keywordArgs);
534 if ($guard[0] ==
"negate") {
539 $passed = $this->
reduce($guard) == self::$TRUE;
540 if ($negate) $passed = !$passed;
547 $groupPassed =
false;
552 if ($groupPassed)
break;
560 if (empty($block->args)) {
561 return $block->isVararg || empty($orderedArgs) && empty($keywordArgs);
564 $remainingArgs = $block->args;
566 $remainingArgs =
array();
567 foreach ($block->args
as $arg) {
568 if ($arg[0] ==
"arg" && isset($keywordArgs[$arg[1]])) {
572 $remainingArgs[] = $arg;
578 foreach ($remainingArgs
as $i => $arg) {
581 if (empty($orderedArgs[$i]) || !$this->
eq($arg[1], $orderedArgs[$i])) {
587 if (!isset($orderedArgs[$i]) && !isset($arg[2])) {
597 if ($block->isVararg) {
600 $numMatched = $i + 1;
602 return $numMatched >= count($orderedArgs);
608 foreach ($blocks
as $block) {
610 if (isset($skip[$block->id]) && !isset($block->args)) {
614 if ($this->
patternMatch($block, $orderedArgs, $keywordArgs)) {
624 if ($searchIn ==
null)
return null;
625 if (isset($seen[$searchIn->id]))
return null;
626 $seen[$searchIn->id] =
true;
630 if (isset($searchIn->children[
$name])) {
631 $blocks = $searchIn->children[
$name];
632 if (count(
$path) == 1) {
641 foreach ($blocks
as $subBlock) {
643 array_slice(
$path, 1), $orderedArgs, $keywordArgs, $seen);
645 if (!is_null($subMatches)) {
646 foreach ($subMatches
as $sm) {
655 if ($searchIn->parent === $searchIn)
return null;
656 return $this->
findBlocks($searchIn->parent,
$path, $orderedArgs, $keywordArgs, $seen);
662 $assignedValues =
array();
666 if ($a[0] ==
"arg") {
667 if (isset($keywordValues[$a[1]])) {
669 $value = $keywordValues[$a[1]];
670 } elseif (isset($orderedValues[$i])) {
672 $value = $orderedValues[$i];
674 } elseif (isset($a[2])) {
678 $this->
throwError(
"Failed to assign arg " . $a[1]);
684 $assignedValues[] =
$value;
693 if (
$last[0] ==
"rest") {
694 $rest = array_slice($orderedValues, count(
$args) - 1);
699 $this->env->arguments = $assignedValues + $orderedValues;
705 $this->sourceLoc = isset($prop[-1]) ? $prop[-1] : -1;
710 if (
$name[0] == $this->vPrefix) {
713 $out->lines[] = $this->formatter->property(
$name,
718 list(, $child) = $prop;
724 $orderedArgs =
array();
725 $keywordArgs =
array();
730 if (!isset($arg[2])) {
731 $orderedArgs[] = $this->
reduce(
array(
"variable", $arg[1]));
733 $keywordArgs[$arg[1]] = $this->
reduce($arg[2]);
738 $orderedArgs[] = $this->
reduce($arg[1]);
741 $this->
throwError(
"Unknown arg type: " . $arg[0]);
745 $mixins = $this->
findBlocks($block,
$path, $orderedArgs, $keywordArgs);
747 if ($mixins ===
null) {
748 $this->
throwError(
"{$prop[1][0]} is undefined");
751 foreach ($mixins
as $mixin) {
752 if ($mixin === $block && !$orderedArgs) {
757 if (isset($mixin->parent->scope)) {
759 $mixinParentEnv = $this->
pushEnv();
760 $mixinParentEnv->storeParent = $mixin->parent->scope;
764 if (isset($mixin->args)) {
767 $this->
zipSetArgs($mixin->args, $orderedArgs, $keywordArgs);
770 $oldParent = $mixin->parent;
771 if ($mixin != $block) $mixin->parent = $block;
773 foreach ($this->
sortProps($mixin->props)
as $subProp) {
774 if ($suffix !==
null &&
775 $subProp[0] ==
"assign" &&
776 is_string($subProp[1]) &&
788 $mixin->parent = $oldParent;
790 if ($haveArgs) $this->
popEnv();
791 if ($haveScope) $this->
popEnv();
796 $out->lines[] = $prop[1];
803 $out->lines[] = $prop[1];
806 list(, $importPath, $importId) = $prop;
807 $importPath = $this->
reduce($importPath);
809 if (!isset($this->env->imports)) {
810 $this->env->imports =
array();
815 $this->env->imports[$importId] =
$result ===
false ?
821 list(,$importId) = $prop;
822 $import = $this->env->imports[$importId];
823 if ($import[0] ===
false) {
824 if (isset($import[1])) {
825 $out->lines[] = $import[1];
834 $this->
throwError(
"unknown op: {$prop[0]}\n");
857 if (!empty($this->formatter->compressColors)) {
868 if ($this->numberPrecision !==
null) {
869 $num = round($num, $this->numberPrecision);
875 foreach ($content
as &$part) {
876 if (is_array($part)) {
880 return $delim . implode($content) . $delim;
892 return 'rgba('.$r.
','.$g.
','.$b.
','.
$value[4].
')';
895 $h = sprintf(
"#%02x%02x%02x", $r, $g, $b);
897 if (!empty($this->formatter->compressColors)) {
899 if ($h[1] === $h[2] && $h[3] === $h[4] && $h[5] === $h[6]) {
900 $h =
'#' . $h[1] . $h[3] . $h[5];
910 $this->
throwError(
"unknown value type: $value[0]");
942 return array(
"number", $num,
"rad");
947 return array(
"number", $num,
"rad");
952 return array(
"number", $num,
"rad");
963 if ($list[0] ==
"list" && isset($list[2][$idx - 1])) {
964 return $list[2][$idx - 1];
1002 if (is_null($color))
1003 $this->
throwError(
"color expected for rgbahex");
1005 return sprintf(
"#%02x%02x%02x%02x",
1006 isset($color[4]) ? $color[4]*255 : 255,
1007 $color[1],$color[2], $color[3]);
1026 if($fullpath && ($fsize = filesize($fullpath)) !==
false) {
1028 if($fsize/1024 < 32) {
1029 if(is_null(
$mime)) {
1030 if(class_exists(
'finfo')) {
1031 $finfo =
new finfo(FILEINFO_MIME);
1032 $mime = explode(
'; ', $finfo->file($fullpath));
1034 } elseif(function_exists(
'mime_content_type')) {
1035 $mime = mime_content_type($fullpath);
1040 $url = sprintf(
'data:%s;base64,%s',
$mime, base64_encode(file_get_contents($fullpath)));
1044 return 'url("'.$url.
'")';
1052 if (isset($items[0])) {
1053 return $this->
lib_e($items[0]);
1069 $string = array_shift($values);
1073 if (preg_match_all(
'/%[dsa]/', $template, $m)) {
1074 foreach ($m[0]
as $match) {
1075 $val = isset($values[$i]) ?
1076 $this->
reduce($values[$i]) :
array(
'keyword',
'');
1085 $template = preg_replace(
'/'.self::preg_quote($match).
'/',
1086 $rep, $template, 1);
1090 $d = $string[0] ==
"string" ? $string[1] :
'"';
1091 return array(
"string", $d,
array($template));
1105 if($arg[0] !=
"list") {
1111 return array(
"number", round(
$value, $precision), $arg[2][0][2]);
1116 if ($arg[0] ==
"list") {
1117 list($number, $newUnit) = $arg[2];
1130 if (
$args[0] !=
'list' || count(
$args[2]) < 2) {
1135 $delta = floatval($delta[1]);
1137 return array($color, $delta);
1143 $hsl = $this->
toHSL($color);
1144 $hsl[3] = $this->
clamp($hsl[3] - $delta, 100);
1145 return $this->
toRGB($hsl);
1151 $hsl = $this->
toHSL($color);
1152 $hsl[3] = $this->
clamp($hsl[3] + $delta, 100);
1153 return $this->
toRGB($hsl);
1159 $hsl = $this->
toHSL($color);
1160 $hsl[2] = $this->
clamp($hsl[2] + $delta, 100);
1161 return $this->
toRGB($hsl);
1167 $hsl = $this->
toHSL($color);
1168 $hsl[2] = $this->
clamp($hsl[2] - $delta, 100);
1169 return $this->
toRGB($hsl);
1175 $hsl = $this->
toHSL($color);
1177 $hsl[1] = $hsl[1] + $delta % 360;
1178 if ($hsl[1] < 0) $hsl[1] += 360;
1180 return $this->
toRGB($hsl);
1185 $color[4] = $this->
clamp((isset($color[4]) ? $color[4] : 1) - $delta/100);
1191 $color[4] = $this->
clamp((isset($color[4]) ? $color[4] : 1) + $delta/100);
1197 return round($hsl[1]);
1202 return round($hsl[2]);
1207 return round($hsl[3]);
1214 return isset($color[4]) ? $color[4] : 1;
1221 $color[4] = $this->
clamp($alpha / 100.0);
1227 return array(
"number", $num*100,
"%");
1234 if (
$args[0] !=
"list" || count(
$args[2]) < 2)
1235 $this->
throwError(
"mix expects (color1, color2, weight)");
1244 if (isset(
$args[2][2])) {
1245 $weight =
$args[2][2][1] / 100.0;
1250 $w = $weight * 2 - 1;
1251 $a = $first_a - $second_a;
1253 $w1 = (($w * $a == -1 ? $w : ($w + $a)/(1 + $w * $a)) + 1) / 2.0;
1256 $new =
array(
'color',
1257 $w1 * $first[1] + $w2 * $second[1],
1258 $w1 * $first[2] + $w2 * $second[2],
1259 $w1 * $first[3] + $w2 * $second[3],
1262 if ($first_a != 1.0 || $second_a != 1.0) {
1263 $new[] = $first_a * $weight + $second_a * ($weight - 1);
1270 $darkColor =
array(
'color', 0, 0, 0);
1271 $lightColor =
array(
'color', 255, 255, 255);
1274 if (
$args[0] ==
'list' ) {
1291 $lightColor = $darkColor;
1295 $inputColor_alpha = $this->
lib_alpha($inputColor);
1296 if ( ( $this->
lib_luma($inputColor) * $inputColor_alpha) < $threshold) {
1304 return (0.2126 * $color[0] / 255) + (0.7152 * $color[1] / 255) + (0.0722 * $color[2] / 255);
1320 if ($expectedArgs == 1) {
1325 $numValues = count($values);
1326 if ($expectedArgs != $numValues) {
1331 $this->
throwError(
"${name}expecting $expectedArgs arguments, got $numValues");
1339 if ($color[0] ==
'hsl')
return $color;
1341 $r = $color[1] / 255;
1342 $g = $color[2] / 255;
1343 $b = $color[3] / 255;
1345 $min = min($r, $g, $b);
1346 $max = max($r, $g, $b);
1348 $L = ($min + $max) / 2;
1353 $S = ($max - $min)/($max + $min);
1355 $S = ($max - $min)/(2.0 - $max - $min);
1357 if ($r == $max) $H = ($g - $b)/($max - $min);
1358 elseif ($g == $max) $H = 2.0 + ($b - $r)/($max - $min);
1359 elseif ($b == $max) $H = 4.0 + ($r - $g)/($max - $min);
1364 ($H < 0 ? $H + 6 : $H)*60,
1369 if (count($color) > 4)
$out[] = $color[4];
1374 if ($comp < 0) $comp += 1.0;
1375 elseif ($comp > 1) $comp -= 1.0;
1377 if (6 * $comp < 1)
return $temp1 + ($temp2 - $temp1) * 6 * $comp;
1378 if (2 * $comp < 1)
return $temp2;
1379 if (3 * $comp < 2)
return $temp1 + ($temp2 - $temp1)*((2/3) - $comp) * 6;
1389 if ($color[0] ==
'color')
return $color;
1391 $H = $color[1] / 360;
1392 $S = $color[2] / 100;
1393 $L = $color[3] / 100;
1402 $temp1 = 2.0 * $L - $temp2;
1410 $out =
array(
'color', $r*255, $g*255, $b*255);
1411 if (count($color) > 4)
$out[] = $color[4];
1415 protected function clamp($v, $max = 1, $min = 0) {
1416 return min($max, max($min, $v));
1425 if ($func[2][0] !=
'list')
return false;
1426 $rawComponents = $func[2][2];
1429 $hsl =
array(
'hsl');
1431 foreach ($rawComponents
as $c) {
1432 $val = $this->
reduce($c);
1433 $val = isset($val[1]) ? floatval($val[1]) : 0;
1435 if ($i == 0) $clamp = 360;
1436 elseif ($i < 3) $clamp = 100;
1439 $hsl[] = $this->
clamp($val, $clamp);
1443 while (count($hsl) < 4) $hsl[] = 0;
1444 return $this->
toRGB($hsl);
1447 $components =
array();
1449 foreach ($rawComponents
as $c) {
1452 if ($c[0] ==
"number" && $c[2] ==
"%") {
1453 $components[] = 255 * ($c[1] / 100);
1455 $components[] = floatval($c[1]);
1457 } elseif ($i == 4) {
1458 if ($c[0] ==
"number" && $c[2] ==
"%") {
1459 $components[] = 1.0 * ($c[1] / 100);
1461 $components[] = floatval($c[1]);
1467 while (count($components) < 3) $components[] = 0;
1468 array_unshift($components,
'color');
1469 return $this->
fixColor($components);
1482 if (
$res[0] ==
"raw_color") {
1491 if (is_array($key)) {
1492 $key = $this->
reduce($key);
1496 $seen =& $this->env->seenNames;
1498 if (!empty($seen[$key])) {
1499 $this->
throwError(
"infinite loop detected: $key");
1504 $seen[$key] =
false;
1508 $item = $this->
reduce($item, $forExpression);
1515 if (is_array($part)) {
1516 $strip = $part[0] ==
"variable";
1517 $part = $this->
reduce($part);
1518 if ($strip) $part = $this->
lib_e($part);
1527 if ($color)
return $color;
1532 $f = isset($this->libFunctions[
$name]) ?
1533 $this->libFunctions[
$name] :
array($this,
'lib_'.str_replace(
'-',
'_',
$name));
1535 if (is_callable(
$f)) {
1536 if (
$args[0] ==
'list')
1541 if (is_null(
$ret)) {
1559 $exp = $this->
reduce($exp);
1561 if ($exp[0] ==
"number") {
1570 return array(
"string",
"",
array($op, $exp));
1573 if ($forExpression) {
1592 case 'color':
return $value;
1594 $c =
array(
"color", 0, 0, 0);
1595 $colorStr = substr(
$value[1], 1);
1596 $num = hexdec($colorStr);
1597 $width = strlen($colorStr) == 3 ? 16 : 256;
1599 for ($i = 3; $i > 0; $i--) {
1603 $c[$i] =
$t * (256/$width) +
$t * floor(16/$width);
1609 if (isset(self::$cssColors[
$name])) {
1610 $rgba = explode(
',', self::$cssColors[
$name]);
1613 return array(
'color', $rgba[0], $rgba[1], $rgba[2], $rgba[3]);
1615 return array(
'color', $rgba[0], $rgba[1], $rgba[2]);
1641 if ($a)
return self::$TRUE;
1642 else return self::$FALSE;
1647 list(, $op, $left,
$right, $whiteBefore, $whiteAfter) = $exp;
1649 $left = $this->
reduce($left,
true);
1665 return $this->
toBool($left == self::$TRUE &&
$right == self::$TRUE);
1677 $fname =
"op_${ltype}_${rtype}";
1685 if ($whiteBefore) $paddedOp =
" " . $paddedOp;
1686 if ($whiteAfter) $paddedOp .=
" ";
1693 if (
$right[0] ==
"string") {
1701 array_unshift($strRight[2], $left);
1709 foreach (range(1, 3)
as $i) {
1710 if ($c[$i] < 0) $c[$i] = 0;
1711 if ($c[$i] > 255) $c[$i] = 255;
1718 if ($op ==
'+' || $op ==
'*') {
1724 if ($rgt[0] ==
'%') $rgt[1] /= 100;
1727 array_fill(1, count($lft) - 1, $rgt[1]));
1732 $max = count($left) > count(
$right) ? count($left) : count(
$right);
1733 foreach (range(1, $max - 1)
as $i) {
1734 $lval = isset($left[$i]) ? $left[$i] : 0;
1738 $out[] = $lval + $rval;
1741 $out[] = $lval - $rval;
1744 $out[] = $lval * $rval;
1747 $out[] = $lval % $rval;
1750 if ($rval == 0) $this->
throwError(
"evaluate error: can't divide by zero");
1751 $out[] = $lval / $rval;
1754 $this->
throwError(
'evaluate error: color op number failed on op '.$op);
1762 if (is_null($color)) {
1763 $this->
throwError(
'color expected for red()');
1771 if (is_null($color)) {
1772 $this->
throwError(
'color expected for green()');
1780 if (is_null($color)) {
1781 $this->
throwError(
'color expected for blue()');
1790 $unit = empty($left[2]) ?
$right[2] : $left[2];
1819 $this->
throwError(
'parse error: unknown number operator: '.$op);
1830 $b->lines =
array();
1831 $b->children =
array();
1832 $b->selectors = $selectors;
1834 $b->parent = $this->scope;
1841 $e->parent = $this->env;
1852 $this->env = $this->env->parent;
1864 $current = $this->env;
1866 $isArguments =
$name == $this->vPrefix .
'arguments';
1868 if ($isArguments && isset($current->arguments)) {
1869 return array(
'list',
' ', $current->arguments);
1872 if (isset($current->store[
$name]))
1873 return $current->store[
$name];
1875 $current = isset($current->storeParent) ?
1876 $current->storeParent : $current->parent;
1880 $this->
throwError(
"variable $name is undefined");
1890 $parser->buffer = (string)$strValue;
1892 throw new Exception(
"failed to parse passed in variable $name: $strValue");
1906 $this->_parseFile =
$fname;
1911 $locale = setlocale(LC_NUMERIC, 0);
1912 setlocale(LC_NUMERIC,
"C");
1915 $root = $this->parser->parse($string);
1918 $this->scope =
null;
1922 if (!empty($this->registeredVars)) {
1930 $this->formatter->block($this->scope);
1931 $out = ob_get_clean();
1932 setlocale(LC_NUMERIC, $locale);
1937 if (!is_readable(
$fname)) {
1938 throw new Exception(
'load error: failed to find '.
$fname);
1945 $this->importDir = (
array)$this->importDir;
1946 $this->importDir[] = $pi[
'dirname'].
'/';
1952 $this->importDir = $oldImport;
1954 if ($outFname !==
null) {
1955 return file_put_contents($outFname,
$out);
1963 if (!is_file(
$out) || filemtime(
$in) > filemtime(
$out)) {
1994 if (is_string(
$in)) {
1996 } elseif (is_array(
$in) and isset(
$in[
'root'])) {
1997 if ($force or ! isset(
$in[
'files'])) {
2001 $root =
$in[
'root'];
2002 } elseif (isset(
$in[
'files']) and is_array(
$in[
'files'])) {
2004 if (!file_exists(
$fname) or filemtime(
$fname) > $ftime) {
2007 $root =
$in[
'root'];
2018 if ($root !==
null) {
2021 $out[
'root'] = $root;
2024 $out[
'updated'] = time();
2036 public function parse($str =
null, $initialVariables =
null) {
2037 if (is_array($str)) {
2038 $initialVariables = $str;
2043 if ($initialVariables !==
null) {
2048 if (empty($this->_parseFile)) {
2049 throw new exception(
"nothing to parse");
2057 $this->registeredVars = $oldVars;
2069 $this->formatterName =
$name;
2073 $className =
"lessc_formatter_lessjs";
2074 if (!empty($this->formatterName)) {
2075 if (!is_string($this->formatterName))
2076 return $this->formatterName;
2077 $className =
"lessc_formatter_$this->formatterName";
2080 return new $className;
2084 $this->preserveComments = $preserve;
2088 $this->libFunctions[
$name] = $func;
2092 unset($this->libFunctions[
$name]);
2096 $this->registeredVars = array_merge($this->registeredVars, $variables);
2100 unset($this->registeredVars[
$name]);
2108 $this->importDir = (
array)$this->importDir;
2109 $this->importDir[] =
$dir;
2124 if ($this->sourceLoc >= 0) {
2125 $this->sourceParser->throwError($msg, $this->sourceLoc);
2127 throw new exception($msg);
2133 if ($less ===
null) {
2136 return $less->checkedCompile(
$in,
$out);
2140 if ($less ===
null) {
2143 return $less->cachedCompile(
$in, $force);
2147 'aliceblue' =>
'240,248,255',
2148 'antiquewhite' =>
'250,235,215',
2149 'aqua' =>
'0,255,255',
2150 'aquamarine' =>
'127,255,212',
2151 'azure' =>
'240,255,255',
2152 'beige' =>
'245,245,220',
2153 'bisque' =>
'255,228,196',
2155 'blanchedalmond' =>
'255,235,205',
2156 'blue' =>
'0,0,255',
2157 'blueviolet' =>
'138,43,226',
2158 'brown' =>
'165,42,42',
2159 'burlywood' =>
'222,184,135',
2160 'cadetblue' =>
'95,158,160',
2161 'chartreuse' =>
'127,255,0',
2162 'chocolate' =>
'210,105,30',
2163 'coral' =>
'255,127,80',
2164 'cornflowerblue' =>
'100,149,237',
2165 'cornsilk' =>
'255,248,220',
2166 'crimson' =>
'220,20,60',
2167 'cyan' =>
'0,255,255',
2168 'darkblue' =>
'0,0,139',
2169 'darkcyan' =>
'0,139,139',
2170 'darkgoldenrod' =>
'184,134,11',
2171 'darkgray' =>
'169,169,169',
2172 'darkgreen' =>
'0,100,0',
2173 'darkgrey' =>
'169,169,169',
2174 'darkkhaki' =>
'189,183,107',
2175 'darkmagenta' =>
'139,0,139',
2176 'darkolivegreen' =>
'85,107,47',
2177 'darkorange' =>
'255,140,0',
2178 'darkorchid' =>
'153,50,204',
2179 'darkred' =>
'139,0,0',
2180 'darksalmon' =>
'233,150,122',
2181 'darkseagreen' =>
'143,188,143',
2182 'darkslateblue' =>
'72,61,139',
2183 'darkslategray' =>
'47,79,79',
2184 'darkslategrey' =>
'47,79,79',
2185 'darkturquoise' =>
'0,206,209',
2186 'darkviolet' =>
'148,0,211',
2187 'deeppink' =>
'255,20,147',
2188 'deepskyblue' =>
'0,191,255',
2189 'dimgray' =>
'105,105,105',
2190 'dimgrey' =>
'105,105,105',
2191 'dodgerblue' =>
'30,144,255',
2192 'firebrick' =>
'178,34,34',
2193 'floralwhite' =>
'255,250,240',
2194 'forestgreen' =>
'34,139,34',
2195 'fuchsia' =>
'255,0,255',
2196 'gainsboro' =>
'220,220,220',
2197 'ghostwhite' =>
'248,248,255',
2198 'gold' =>
'255,215,0',
2199 'goldenrod' =>
'218,165,32',
2200 'gray' =>
'128,128,128',
2201 'green' =>
'0,128,0',
2202 'greenyellow' =>
'173,255,47',
2203 'grey' =>
'128,128,128',
2204 'honeydew' =>
'240,255,240',
2205 'hotpink' =>
'255,105,180',
2206 'indianred' =>
'205,92,92',
2207 'indigo' =>
'75,0,130',
2208 'ivory' =>
'255,255,240',
2209 'khaki' =>
'240,230,140',
2210 'lavender' =>
'230,230,250',
2211 'lavenderblush' =>
'255,240,245',
2212 'lawngreen' =>
'124,252,0',
2213 'lemonchiffon' =>
'255,250,205',
2214 'lightblue' =>
'173,216,230',
2215 'lightcoral' =>
'240,128,128',
2216 'lightcyan' =>
'224,255,255',
2217 'lightgoldenrodyellow' =>
'250,250,210',
2218 'lightgray' =>
'211,211,211',
2219 'lightgreen' =>
'144,238,144',
2220 'lightgrey' =>
'211,211,211',
2221 'lightpink' =>
'255,182,193',
2222 'lightsalmon' =>
'255,160,122',
2223 'lightseagreen' =>
'32,178,170',
2224 'lightskyblue' =>
'135,206,250',
2225 'lightslategray' =>
'119,136,153',
2226 'lightslategrey' =>
'119,136,153',
2227 'lightsteelblue' =>
'176,196,222',
2228 'lightyellow' =>
'255,255,224',
2229 'lime' =>
'0,255,0',
2230 'limegreen' =>
'50,205,50',
2231 'linen' =>
'250,240,230',
2232 'magenta' =>
'255,0,255',
2233 'maroon' =>
'128,0,0',
2234 'mediumaquamarine' =>
'102,205,170',
2235 'mediumblue' =>
'0,0,205',
2236 'mediumorchid' =>
'186,85,211',
2237 'mediumpurple' =>
'147,112,219',
2238 'mediumseagreen' =>
'60,179,113',
2239 'mediumslateblue' =>
'123,104,238',
2240 'mediumspringgreen' =>
'0,250,154',
2241 'mediumturquoise' =>
'72,209,204',
2242 'mediumvioletred' =>
'199,21,133',
2243 'midnightblue' =>
'25,25,112',
2244 'mintcream' =>
'245,255,250',
2245 'mistyrose' =>
'255,228,225',
2246 'moccasin' =>
'255,228,181',
2247 'navajowhite' =>
'255,222,173',
2248 'navy' =>
'0,0,128',
2249 'oldlace' =>
'253,245,230',
2250 'olive' =>
'128,128,0',
2251 'olivedrab' =>
'107,142,35',
2252 'orange' =>
'255,165,0',
2253 'orangered' =>
'255,69,0',
2254 'orchid' =>
'218,112,214',
2255 'palegoldenrod' =>
'238,232,170',
2256 'palegreen' =>
'152,251,152',
2257 'paleturquoise' =>
'175,238,238',
2258 'palevioletred' =>
'219,112,147',
2259 'papayawhip' =>
'255,239,213',
2260 'peachpuff' =>
'255,218,185',
2261 'peru' =>
'205,133,63',
2262 'pink' =>
'255,192,203',
2263 'plum' =>
'221,160,221',
2264 'powderblue' =>
'176,224,230',
2265 'purple' =>
'128,0,128',
2267 'rosybrown' =>
'188,143,143',
2268 'royalblue' =>
'65,105,225',
2269 'saddlebrown' =>
'139,69,19',
2270 'salmon' =>
'250,128,114',
2271 'sandybrown' =>
'244,164,96',
2272 'seagreen' =>
'46,139,87',
2273 'seashell' =>
'255,245,238',
2274 'sienna' =>
'160,82,45',
2275 'silver' =>
'192,192,192',
2276 'skyblue' =>
'135,206,235',
2277 'slateblue' =>
'106,90,205',
2278 'slategray' =>
'112,128,144',
2279 'slategrey' =>
'112,128,144',
2280 'snow' =>
'255,250,250',
2281 'springgreen' =>
'0,255,127',
2282 'steelblue' =>
'70,130,180',
2283 'tan' =>
'210,180,140',
2284 'teal' =>
'0,128,128',
2285 'thistle' =>
'216,191,216',
2286 'tomato' =>
'255,99,71',
2287 'transparent' =>
'0,0,0,0',
2288 'turquoise' =>
'64,224,208',
2289 'violet' =>
'238,130,238',
2290 'wheat' =>
'245,222,179',
2291 'white' =>
'255,255,255',
2292 'whitesmoke' =>
'245,245,245',
2293 'yellow' =>
'255,255,0',
2294 'yellowgreen' =>
'154,205,50'
2329 array(
'/border-radius$/i',
'/^font$/i');
2331 protected $blockDirectives =
array(
"font-face",
"keyframes",
"page",
"-moz-document",
"viewport",
"-moz-viewport",
"-o-viewport",
"-ms-viewport");
2349 $this->eatWhiteDefault =
true;
2351 $this->
lessc = $lessc;
2353 $this->sourceName = $sourceName;
2355 $this->writeComments =
false;
2357 if (!self::$operatorString) {
2358 self::$operatorString =
2359 '('.implode(
'|', array_map(
array(
'lessc',
'preg_quote'),
2360 array_keys(self::$precedence))).
')';
2367 self::$whitePattern =
'/'.$commentSingle.
'[^\n]*\s*|('.self::$commentMulti.
')\s*|\s+/Ais';
2376 $this->buffer = $this->writeComments ? $buffer : $this->
removeComments($buffer);
2378 $this->eatWhiteDefault =
true;
2379 $this->seenComments =
array();
2391 if ($this->count != strlen($this->buffer))
2395 if ( !property_exists($this->env,
'parent') || !is_null($this->env->parent) )
2396 throw new exception(
'parse error: unclosed block');
2438 if (empty($this->buffer))
return false;
2457 if ($this->
literal(
'@',
false)) {
2461 if ($this->
literal(
'@media')) {
2466 $media->queries = is_null($mediaQueries) ?
array() : $mediaQueries;
2475 if ($this->
isDirective($dirName, $this->blockDirectives)) {
2480 $dir->name = $dirName;
2481 if (isset($dirValue))
$dir->value = $dirValue;
2484 } elseif ($this->
isDirective($dirName, $this->lineDirectives)) {
2486 $this->
append(
array(
"directive", $dirName, $dirValue));
2505 if ($this->
import($importValue)) {
2512 ($this->
guards($guards) ||
true) &&
2516 $block->args =
$args;
2517 $block->isVararg = $isVararg;
2518 if (!empty($guards)) $block->guards = $guards;
2525 if ($this->
tags($tags) && $this->
literal(
'{',
false)) {
2526 $tags = $this->
fixTags($tags);
2534 if ($this->
literal(
'}',
false)) {
2536 $block = $this->
pop();
2537 }
catch (exception
$e) {
2543 if (is_null($block->type)) {
2545 if (!isset($block->args)) {
2546 foreach ($block->tags
as $tag) {
2547 if (!is_string($tag) || $tag{0} != $this->
lessc->mPrefix) {
2554 foreach ($block->tags
as $tag) {
2555 if (is_string($tag)) {
2556 $this->env->children[$tag][] = $block;
2574 ($this->
keyword($suffix) ||
true) && $this->
end())
2576 $tags = $this->
fixTags($tags);
2584 if ($this->
literal(
';'))
return true;
2591 $pattern = implode(
"|",
2592 array_map(
array(
"lessc",
"preg_quote"), $directives));
2593 $pattern =
'/^(-[a-z-]+-)?(' . $pattern .
')$/i';
2595 return preg_match($pattern, $dirname);
2600 foreach ($tags
as &$tag) {
2601 if ($tag{0} == $this->
lessc->vPrefix)
2602 $tag[0] = $this->
lessc->mPrefix;
2615 if (count($values) == 0)
return false;
2626 if ($this->
value($lhs)) {
2630 if (!empty($this->env->supressedDivision)) {
2631 unset($this->env->supressedDivision);
2650 $this->inExp =
true;
2651 $ss = $this->
seek();
2654 $whiteBefore = isset($this->buffer[$this->count - 1]) &&
2655 ctype_space($this->buffer[$this->count - 1]);
2661 if ($this->
match(self::$operatorString.($needWhite ?
'\s' :
''), $m) && self::$precedence[$m[1]] >= $minP) {
2662 if (!$this->inParens && isset($this->env->currentProperty) && $m[1] ==
"/" && empty($this->env->supressedDivision)) {
2663 foreach (self::$supressDivisionProps
as $pattern) {
2664 if (preg_match($pattern, $this->env->currentProperty)) {
2665 $this->env->supressedDivision =
true;
2672 $whiteAfter = isset($this->buffer[$this->count - 1]) &&
2673 ctype_space($this->buffer[$this->count - 1]);
2675 if (!$this->
value($rhs))
break;
2678 if ($this->
peek(self::$operatorString, $next) && self::$precedence[$next[1]] > self::$precedence[$m[1]]) {
2679 $rhs = $this->
expHelper($rhs, self::$precedence[$next[1]]);
2682 $lhs =
array(
'expression', $m[1], $lhs, $rhs, $whiteBefore, $whiteAfter);
2683 $ss = $this->
seek();
2700 if ($keyName !==
null) $this->env->currentProperty = $keyName;
2706 if (!$this->
literal(
','))
break;
2711 if ($keyName !==
null) unset($this->env->currentProperty);
2713 if (count($values) == 0)
return false;
2723 if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] !=
"(") {
2729 ($this->inParens =
true) && $this->
expression($exp) &&
2748 if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] ==
"-") {
2750 if ($this->
literal(
"-",
false) &&
2751 (($this->
variable($inner) && $inner =
array(
"variable", $inner)) ||
2752 $this->
unit($inner) ||
2766 if ($this->
string(
$value))
return true;
2780 if ($this->
literal(
"~") && $this->
string($str)) {
2788 if ($this->
literal(
'\\') && $this->
match(
'([0-9]+)', $m)) {
2800 if (!$this->
literal(
'@import'))
return false;
2813 if ($this->
genericList($list,
"mediaQuery",
",",
false)) {
2823 $expressions =
null;
2826 if (($this->
literal(
"only") && ($only =
true) || $this->
literal(
"not") && ($not =
true) ||
true) && $this->
keyword($mediaType)) {
2827 $prop =
array(
"mediaType");
2828 if (isset($only)) $prop[] =
"only";
2829 if (isset($not)) $prop[] =
"not";
2830 $prop[] = $mediaType;
2837 if (!empty($mediaType) && !$this->
literal(
"and")) {
2840 $this->
genericList($expressions,
"mediaExpression",
"and",
false);
2841 if (is_array($expressions)) $parts = array_merge($parts, $expressions[2]);
2844 if (count($parts) == 0) {
2864 } elseif ($this->
variable($variable)) {
2875 $oldWhite = $this->eatWhiteDefault;
2876 $this->eatWhiteDefault =
false;
2878 $stop =
array(
"'",
'"',
"@{", $end);
2879 $stop = array_map(
array(
"lessc",
"preg_quote"), $stop);
2882 if (!is_null($rejectStrs)) {
2883 $stop = array_merge($stop, $rejectStrs);
2886 $patt =
'(.*?)('.implode(
"|", $stop).
')';
2891 while ($this->
match($patt, $m,
false)) {
2892 if (!empty($m[1])) {
2895 $nestingLevel += substr_count($m[1], $nestingOpen);
2901 $this->count-= strlen($tok);
2903 if ($nestingLevel == 0) {
2910 if (($tok ==
"'" || $tok ==
'"') && $this->
string($str)) {
2916 $content[] = $inter;
2920 if (!empty($rejectStrs) && in_array($tok, $rejectStrs)) {
2925 $this->count+= strlen($tok);
2928 $this->eatWhiteDefault = $oldWhite;
2930 if (count($content) == 0)
return false;
2933 if (is_string(
end($content))) {
2934 $content[count($content) - 1] = rtrim(
end($content));
2943 if ($this->
literal(
'"',
false)) {
2945 } elseif ($this->
literal(
"'",
false)) {
2954 $patt =
'([^\n]*?)(@\{|\\\\|' .
2957 $oldWhite = $this->eatWhiteDefault;
2958 $this->eatWhiteDefault =
false;
2960 while ($this->
match($patt, $m,
false)) {
2962 if ($m[2] ==
"@{") {
2963 $this->count -= strlen($m[2]);
2965 $content[] = $inter;
2967 $this->count += strlen($m[2]);
2970 } elseif ($m[2] ==
'\\') {
2972 if ($this->
literal($delim,
false)) {
2973 $content[] = $delim;
2976 $this->count -= strlen($delim);
2981 $this->eatWhiteDefault = $oldWhite;
2984 $out =
array(
"string", $delim, $content);
2993 $oldWhite = $this->eatWhiteDefault;
2994 $this->eatWhiteDefault =
true;
3002 $this->eatWhiteDefault = $oldWhite;
3003 if ($this->eatWhiteDefault) $this->
whitespace();
3007 $this->eatWhiteDefault = $oldWhite;
3014 if (isset($this->buffer[$this->count])) {
3016 if (!ctype_digit($char) && $char !=
".")
return false;
3019 if ($this->
match(
'([0-9]+(?:\.[0-9]*)?|\.[0-9]+)([%a-zA-Z]+)?', $m)) {
3020 $unit =
array(
"number", $m[1], empty($m[2]) ?
"" : $m[2]);
3028 if ($this->
match(
'(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3}))', $m)) {
3029 if (strlen($m[1]) > 7) {
3047 if (!$this->
literal(
'('))
return false;
3051 $method =
"expressionList";
3060 if ($this->$method(
$value)) {
3061 if (
$value[0] ==
"variable") {
3063 $ss = $this->
seek();
3065 if ($this->
assign() && $this->$method($rhs)) {
3076 if ($isVararg)
break;
3084 if (!$this->
literal($delim)) {
3085 if ($delim ==
"," && $this->
literal(
";")) {
3088 $method =
"propertyValue";
3091 if (isset($values[1])) {
3093 foreach ($values
as $i => $arg) {
3097 $this->
throwError(
"Cannot mix ; and , as delimiter types");
3099 $newList[] = $arg[2];
3102 $newList[] = $arg[1];
3105 $this->
throwError(
"Unexpected rest before semicolon");
3109 $newList =
array(
"list",
", ", $newList);
3111 switch ($values[0][0]) {
3113 $newArg =
array(
"arg", $values[0][1], $newList);
3116 $newArg =
array(
"lit", $newList);
3120 } elseif ($values) {
3121 $newArg = $values[0];
3125 $values =
array($newArg);
3145 protected function tags(&$tags, $simple =
false, $delim =
',') {
3147 while ($this->
tag($tt, $simple)) {
3149 if (!$this->
literal($delim))
break;
3151 if (count($tags) == 0)
return false;
3160 while ($this->
tag($tt,
true)) {
3165 if (count($tags) == 0)
return false;
3173 if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] !=
"[") {
3179 $hasInterpolation =
false;
3181 if ($this->
literal(
"[",
false)) {
3182 $attrParts =
array(
"[");
3185 if ($this->
literal(
"]",
false)) {
3190 if ($this->
match(
'\s+', $m)) {
3194 if ($this->
string($str)) {
3196 foreach ($str[2]
as &$chunk) {
3197 $chunk = str_replace($this->
lessc->parentSelector,
"$&$", $chunk);
3200 $attrParts[] = $str;
3201 $hasInterpolation =
true;
3206 $attrParts[] = $word;
3211 $attrParts[] = $inter;
3212 $hasInterpolation =
true;
3217 if ($this->
match(
'[|-~\$\*\^=]+', $m)) {
3218 $attrParts[] = $m[0];
3225 if ($this->
literal(
"]",
false)) {
3227 foreach ($attrParts
as $part) {
3230 $hasExpression = $hasExpression || $hasInterpolation;
3241 protected function tag(&$tag, $simple =
false) {
3243 $chars =
'^@,:;{}\][>\(\) "\'';
3245 $chars =
'^@,;{}["\'';
3249 $hasExpression =
false;
3251 while ($this->
tagBracket($parts, $hasExpression));
3253 $oldWhite = $this->eatWhiteDefault;
3254 $this->eatWhiteDefault =
false;
3257 if ($this->
match(
'(['.$chars.
'0-9]['.$chars.
']*)', $m)) {
3261 while ($this->
tagBracket($parts, $hasExpression));
3265 if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] ==
"@") {
3267 $hasExpression =
true;
3279 if ($this->
unit($unit)) {
3280 $parts[] = $unit[1];
3281 $parts[] = $unit[2];
3288 $this->eatWhiteDefault = $oldWhite;
3294 if ($hasExpression) {
3295 $tag =
array(
"exp",
array(
"string",
"", $parts));
3297 $tag = trim(implode($parts));
3308 if ($this->
match(
'(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->
literal(
'(')) {
3311 $sPreArgs = $this->
seek();
3315 $ss = $this->
seek();
3326 if (!$this->
literal(
','))
break;
3333 } elseif (
$fname ==
'url') {
3335 $this->
seek($sPreArgs);
3377 if ($this->
match(
'([\w_\-\*!"][\w\-_"]*)', $m)) {
3386 if ($this->
literal(
';',
false)) {
3388 } elseif ($this->count == strlen($this->buffer) || $this->buffer[$this->count] ==
'}') {
3398 if (!$this->
literal(
"when")) {
3407 if (!$this->
literal(
","))
break;
3410 if (count($guards) == 0) {
3423 $guardGroup =
array();
3424 while ($this->
guard($guard)) {
3425 $guardGroup[] = $guard;
3426 if (!$this->
literal(
"and"))
break;
3429 if (count($guardGroup) == 0) {
3440 $negate = $this->
literal(
"not");
3444 if ($negate) $guard =
array(
"negate", $guard);
3454 protected function literal($what, $eatWhitespace =
null) {
3455 if ($eatWhitespace ===
null) $eatWhitespace = $this->eatWhiteDefault;
3458 if (!isset($what[1]) && isset($this->buffer[$this->count])) {
3459 if ($this->buffer[$this->count] == $what) {
3460 if (!$eatWhitespace) {
3470 if (!isset(self::$literalCache[$what])) {
3474 return $this->
match(self::$literalCache[$what], $m, $eatWhitespace);
3480 while ($this->$parseItem(
$value)) {
3483 if (!$this->
literal($delim))
break;
3487 if (count($items) == 0) {
3492 if ($flatten && count($items) == 1) {
3505 protected function to($what, &
$out, $until =
false, $allowNewline =
false) {
3506 if (is_string($allowNewline)) {
3507 $validChars = $allowNewline;
3509 $validChars = $allowNewline ?
"." :
"[^\n]";
3512 if ($until) $this->count -= strlen($what);
3518 protected function match($regex, &
$out, $eatWhitespace =
null) {
3519 if ($eatWhitespace ===
null) $eatWhitespace = $this->eatWhiteDefault;
3521 $r =
'/'.$regex.($eatWhitespace && !$this->writeComments ?
'\s*' :
'').
'/Ais';
3522 if (preg_match($r, $this->buffer,
$out,
null, $this->count)) {
3523 $this->count += strlen(
$out[0]);
3524 if ($eatWhitespace && $this->writeComments) $this->
whitespace();
3532 if ($this->writeComments) {
3534 while (preg_match(self::$whitePattern, $this->buffer, $m,
null, $this->count)) {
3535 if (isset($m[1]) && empty($this->seenComments[$this->count])) {
3539 $this->count += strlen($m[0]);
3544 $this->
match(
"", $m);
3545 return strlen($m[0]) > 0;
3552 $r =
'/'.$regex.
'/Ais';
3559 protected function seek($where =
null) {
3561 else $this->count = $where;
3571 substr_count(substr($this->buffer, 0,
$count),
"\n");
3573 if (!empty($this->sourceName)) {
3574 $loc =
"$this->sourceName on line $line";
3576 $loc =
"line: $line";
3580 if ($this->
peek(
"(.*?)(\n|$)", $m,
$count)) {
3581 throw new exception(
"$msg: failed at `$m[1]` $loc");
3583 throw new exception(
"$msg: $loc");
3589 $b->parent = $this->env;
3592 $b->id = self::$nextBlockId++;
3594 $b->isVararg =
false;
3595 $b->tags = $selectors;
3597 $b->props =
array();
3598 $b->children =
array();
3610 protected function append($prop, $pos =
null) {
3611 if ($pos !==
null) $prop[-1] = $pos;
3612 $this->env->props[] = $prop;
3618 $this->env = $this->env->parent;
3626 'url(',
'//',
'/*',
'"',
"'"
3633 foreach ($look
as $token) {
3634 $pos = strpos($text, $token);
3635 if ($pos !==
false) {
3636 if (!isset($min) || $pos < $min[1]) $min =
array($token, $pos);
3640 if (is_null($min))
break;
3647 if (preg_match(
'/url\(.*?\)/', $text, $m, 0,
$count))
3648 $count += strlen($m[0]) - strlen($min[0]);
3652 if (preg_match(
'/'.$min[0].
'.*?(?<!\\\\)'.$min[0].
'/', $text, $m, 0,
$count))
3653 $count += strlen($m[0]) - 1;
3656 $skip = strpos($text,
"\n",
$count);
3657 if ($skip ===
false) $skip = strlen($text) -
$count;
3661 if (preg_match(
'/\/\*.*?\*\//s', $text, $m, 0,
$count)) {
3662 $skip = strlen($m[0]);
3663 $newlines = substr_count($m[0],
"\n");
3668 if ($skip == 0)
$count += strlen($min[0]);
3670 $out .= substr($text, 0,
$count).str_repeat(
"\n", $newlines);
3671 $text = substr($text,
$count + $skip);
3699 $this->indentLevel = 0;
3703 return str_repeat($this->indentChar, max($this->indentLevel +
$n, 0));
3707 return $name . $this->assignSeparator .
$value .
";";
3711 if (empty($block->lines)) {
3712 foreach ($block->children
as $child) {
3713 if (!$this->
isEmpty($child))
return false;
3722 if ($this->
isEmpty($block))
return;
3726 $isSingle = !$this->disableSingle &&
3727 is_null($block->type) && count($block->lines) == 1;
3729 if (!empty($block->selectors)) {
3730 $this->indentLevel++;
3732 if ($this->breakSelectors) {
3750 if (!empty($block->lines)) {
3751 $glue = $this->
break.$inner;
3752 echo $inner . implode($glue, $block->lines);
3753 if (!$isSingle && !empty($block->children)) {
3758 foreach ($block->children
as $child) {
3759 $this->
block($child);
3762 if (!empty($block->selectors)) {
3763 if (!$isSingle && empty($block->children)) echo
$this->break;
3771 $this->indentLevel--;