diff --git a/scss.inc.php b/scss.inc.php index 30d872d9..f9bc9008 100644 --- a/scss.inc.php +++ b/scss.inc.php @@ -2734,16 +2734,13 @@ protected function parseChunk() { $this->literal(":") && $this->valueList($value) && $this->end()) { - $defaultVar = false; // check for !default - if ($value[0] == "list") { - $def = end($value[2]); - if ($def[0] == "keyword" && $def[1] == "!default") { - array_pop($value[2]); - $value = $this->flattenList($value); - $defaultVar = true; - } + $defaultVar = $value[0] == "list" && $this->stripDefault($value); + if (!$defaultVar && isset($value[2]) && is_array($value[2])) { + $nestedValue = end($value[2]); + $defaultVar = is_array($nestedValue) && $nestedValue[0] == "list" && $this->stripDefault($value[2][count($value[2]) - 1]); } + $this->append(array("assign", $name, $value, $defaultVar), $s); return true; } else { @@ -2817,6 +2814,17 @@ protected function parseChunk() { return false; } + protected function stripDefault(&$value) { + $def = end($value[2]); + if ($def[0] == "keyword" && $def[1] == "!default") { + array_pop($value[2]); + $value = $this->flattenList($value); + return true; + } + + return false; + } + protected function literal($what, $eatWhitespace = null) { if (is_null($eatWhitespace)) $eatWhitespace = $this->eatWhiteDefault; diff --git a/tests/inputs/variables.scss b/tests/inputs/variables.scss index 3606b01e..bebd4dc7 100644 --- a/tests/inputs/variables.scss +++ b/tests/inputs/variables.scss @@ -41,3 +41,16 @@ del { color: $something; } +$font-family-simple: Arial !default; +$font-family-spaces: Helvetica Neue !default; +$font-family-quotes: "Helvetica Neue" !default; +$font-family-commas: Helvetica, Arial, sans-serif !default; +$font-family-sans: "Helvetica Neue", Helvetica, Arial, sans-serif !default; + +body { + font-family: $font-family-simple; + font-family: $font-family-spaces; + font-family: $font-family-quotes; + font-family: $font-family-commas; + font-family: $font-family-sans; +} diff --git a/tests/outputs/variables.css b/tests/outputs/variables.css index 3cfed718..86763380 100644 --- a/tests/outputs/variables.css +++ b/tests/outputs/variables.css @@ -15,3 +15,10 @@ del { color: red; } del div pre { color: red; } + +body { + font-family: Arial; + font-family: Helvetica Neue; + font-family: "Helvetica Neue"; + font-family: Helvetica, Arial, sans-serif; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; }