diff --git a/composer.json b/composer.json index 95118a32..ba163dc2 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "leafo/scssphp", + "name": "arlisaha/scssphp", "type": "library", - "description": "scssphp is a compiler for SCSS written in PHP.", + "description": "Fork from Leafo SCSS PHP compiler (see homepage).", "keywords": ["css", "stylesheet", "scss", "sass", "less"], "homepage": "http://leafo.github.io/scssphp/", "license": [ diff --git a/src/Node/Number.php b/src/Node/Number.php index 442d57d5..bbfb3799 100644 --- a/src/Node/Number.php +++ b/src/Node/Number.php @@ -32,6 +32,10 @@ class Number extends Node implements \ArrayAccess * @var integer */ static public $precision = 5; + + static public $decSeparator = '.'; + + static public $thouSeparator = ''; /** * @see http://www.w3.org/TR/2012/WD-css3-values-20120308/ @@ -265,7 +269,7 @@ public function unitStr() */ public function output(Compiler $compiler = null) { - $dimension = round($this->dimension, static::$precision); + $dimension = $this->round($this->dimension);; $units = array_filter($this->units, function ($unitSize) { return $unitSize; @@ -277,7 +281,7 @@ public function output(Compiler $compiler = null) $this->normalizeUnits($dimension, $units, 'in'); - $dimension = round($dimension, static::$precision); + $dimension = $this->round($dimension); $units = array_filter($units, function ($unitSize) { return $unitSize; }); @@ -294,6 +298,27 @@ public function output(Compiler $compiler = null) return (string) $dimension . $unit; } + + /** + * Round number with proper separators + * + * @param $dimension + * + * @return string + */ + protected function round($dimension) + { + return rtrim( + rtrim( + number_format( + round($dimension, static::$precision), + static::$precision, + static::$decSeparator, + static::$thouSeparator + ), + '0'), + '.'); + } /** * {@inheritdoc}