|
|
@@ -20,7 +20,7 @@ class Less_Parser{
|
|
|
'strictUnits' => false, // whether units need to evaluate correctly
|
|
|
'strictMath' => false, // whether math has to be within parenthesis
|
|
|
'relativeUrls' => true, // option - whether to adjust URL's to be relative
|
|
|
- 'urlArgs' => array(), // whether to add args into url tokens
|
|
|
+ 'urlArgs' => '', // whether to add args into url tokens
|
|
|
'numPrecision' => 8,
|
|
|
|
|
|
'import_dirs' => array(),
|
|
|
@@ -35,6 +35,8 @@ class Less_Parser{
|
|
|
'sourceMapWriteTo' => null,
|
|
|
'sourceMapURL' => null,
|
|
|
|
|
|
+ 'indentation' => ' ',
|
|
|
+
|
|
|
'plugins' => array(),
|
|
|
|
|
|
);
|
|
|
@@ -87,7 +89,7 @@ class Less_Parser{
|
|
|
// mbstring.func_overload > 1 bugfix
|
|
|
// The encoding value must be set for each source file,
|
|
|
// therefore, to conserve resources and improve the speed of this design is taken here
|
|
|
- if (ini_get('mbstring.func_overload')) {
|
|
|
+ if (ini_get('mbstring.func_overload')) {
|
|
|
$this->mb_internal_encoding = ini_get('mbstring.internal_encoding');
|
|
|
@ini_set('mbstring.internal_encoding', 'ascii');
|
|
|
}
|
|
|
@@ -220,7 +222,7 @@ class Less_Parser{
|
|
|
@ini_set('precision',$precision);
|
|
|
setlocale(LC_NUMERIC, $locale);
|
|
|
|
|
|
- // If you previously defined $this->mb_internal_encoding
|
|
|
+ // If you previously defined $this->mb_internal_encoding
|
|
|
// is required to return the encoding as it was before
|
|
|
if ($this->mb_internal_encoding != '') {
|
|
|
@ini_set("mbstring.internal_encoding", $this->mb_internal_encoding);
|
|
|
@@ -1989,7 +1991,7 @@ class Less_Parser{
|
|
|
}
|
|
|
|
|
|
private function parseImportOption(){
|
|
|
- $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference)/');
|
|
|
+ $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference|optional)/');
|
|
|
if( $opt ){
|
|
|
return $opt[1];
|
|
|
}
|
|
|
@@ -2623,8 +2625,6 @@ class Less_Parser{
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -3702,7 +3702,7 @@ class Less_Functions{
|
|
|
|
|
|
public function argb($color) {
|
|
|
if (!$color instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return new Less_Tree_Anonymous($color->toARGB());
|
|
|
@@ -3997,10 +3997,10 @@ class Less_Functions{
|
|
|
|
|
|
public function multiply($color1 = null, $color2 = null ){
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 );
|
|
|
@@ -4012,10 +4012,10 @@ class Less_Functions{
|
|
|
|
|
|
public function screen($color1 = null, $color2 = null ){
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 );
|
|
|
@@ -4027,10 +4027,10 @@ class Less_Functions{
|
|
|
|
|
|
public function overlay($color1 = null, $color2 = null){
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 );
|
|
|
@@ -4045,10 +4045,10 @@ class Less_Functions{
|
|
|
|
|
|
public function softlight($color1 = null, $color2 = null){
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 );
|
|
|
@@ -4067,10 +4067,10 @@ class Less_Functions{
|
|
|
|
|
|
public function hardlight($color1 = null, $color2 = null){
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 );
|
|
|
@@ -4082,10 +4082,10 @@ class Less_Functions{
|
|
|
|
|
|
public function difference($color1 = null, $color2 = null) {
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 );
|
|
|
@@ -4097,10 +4097,10 @@ class Less_Functions{
|
|
|
|
|
|
public function exclusion( $color1 = null, $color2 = null ){
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 );
|
|
|
@@ -4112,10 +4112,10 @@ class Less_Functions{
|
|
|
|
|
|
public function average($color1 = null, $color2 = null){
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 );
|
|
|
@@ -4128,10 +4128,10 @@ class Less_Functions{
|
|
|
|
|
|
public function negation($color1 = null, $color2 = null ){
|
|
|
if (!$color1 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
if (!$color2 instanceof Less_Tree_Color) {
|
|
|
- throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
+ throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
|
|
|
}
|
|
|
|
|
|
return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 );
|
|
|
@@ -4236,8 +4236,8 @@ class Less_Tree{
|
|
|
|
|
|
|
|
|
// Non-compressed
|
|
|
- $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 );
|
|
|
- $tabRuleStr = $tabSetStr.' ';
|
|
|
+ $tabSetStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel-1 );
|
|
|
+ $tabRuleStr = $tabSetStr.Less_Parser::$options['indentation'];
|
|
|
|
|
|
$output->add( " {" );
|
|
|
for($i = 0; $i < $ruleCnt; $i++ ){
|
|
|
@@ -4274,7 +4274,8 @@ class Less_Tree{
|
|
|
return $obj;
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Parser output
|
|
|
@@ -5361,7 +5362,7 @@ class Less_Tree_Dimension extends Less_Tree{
|
|
|
$other = $other->convertTo( $this->unit->usedUnits());
|
|
|
|
|
|
if( Less_Parser::$options['strictUnits'] && $other->unit->toString() !== $unit->toCSS() ){
|
|
|
- throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString() . "' and ".$other->unit->toString()+"'.");
|
|
|
+ throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '" . $unit->toString() . "' and " . $other->unit->toString() . "'.");
|
|
|
}
|
|
|
|
|
|
$value = Less_Functions::operate( $op, $this->value, $other->value);
|
|
|
@@ -5994,6 +5995,11 @@ class Less_Tree_Import extends Less_Tree{
|
|
|
return array( $contents );
|
|
|
}
|
|
|
|
|
|
+ // optional (need to be before "CSS" to support optional CSS imports. CSS should be checked only if empty($this->currentFileInfo))
|
|
|
+ if( isset($this->options['optional']) && $this->options['optional'] && !file_exists($full_path) && (!$evald->css || !empty($this->currentFileInfo))) {
|
|
|
+ return array();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// css ?
|
|
|
if( $evald->css ){
|
|
|
@@ -6116,7 +6122,6 @@ class Less_Tree_Import extends Less_Tree{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -6389,6 +6394,7 @@ class Less_Tree_NameValue extends Less_Tree{
|
|
|
public $index;
|
|
|
public $currentFileInfo;
|
|
|
public $type = 'NameValue';
|
|
|
+ public $important = '';
|
|
|
|
|
|
public function __construct($name, $value = null, $index = null, $currentFileInfo = null ){
|
|
|
$this->name = $name;
|
|
|
@@ -6403,6 +6409,7 @@ class Less_Tree_NameValue extends Less_Tree{
|
|
|
$this->name
|
|
|
. Less_Environment::$_outputMap[': ']
|
|
|
. $this->value
|
|
|
+ . $this->important
|
|
|
. (((Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";")
|
|
|
, $this->currentFileInfo, $this->index);
|
|
|
}
|
|
|
@@ -6410,6 +6417,14 @@ class Less_Tree_NameValue extends Less_Tree{
|
|
|
public function compile ($env){
|
|
|
return $this;
|
|
|
}
|
|
|
+
|
|
|
+ public function makeImportant(){
|
|
|
+ $new = new Less_Tree_NameValue($this->name, $this->value, $this->index, $this->currentFileInfo);
|
|
|
+ $new->important = ' !important';
|
|
|
+ return $new;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -7014,7 +7029,7 @@ class Less_Tree_Ruleset extends Less_Tree{
|
|
|
|
|
|
$important_rules = array();
|
|
|
foreach($this->rules as $rule){
|
|
|
- if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){
|
|
|
+ if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset || $rule instanceof Less_Tree_NameValue ){
|
|
|
$important_rules[] = $rule->makeImportant();
|
|
|
}else{
|
|
|
$important_rules[] = $rule;
|
|
|
@@ -7115,8 +7130,8 @@ class Less_Tree_Ruleset extends Less_Tree{
|
|
|
$tabRuleStr = $tabSetStr = '';
|
|
|
if( !Less_Parser::$options['compress'] ){
|
|
|
if( Less_Environment::$tabLevel ){
|
|
|
- $tabRuleStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel );
|
|
|
- $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 );
|
|
|
+ $tabRuleStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel );
|
|
|
+ $tabSetStr = "\n".str_repeat( Less_Parser::$options['indentation'] , Less_Environment::$tabLevel-1 );
|
|
|
}else{
|
|
|
$tabSetStr = $tabRuleStr = "\n";
|
|
|
}
|
|
|
@@ -8080,7 +8095,7 @@ class Less_Tree_Mixin_Call extends Less_Tree{
|
|
|
} else {
|
|
|
$defaultResult = $defTrue;
|
|
|
if( ($count[$defTrue] + $count[$defFalse]) > 1 ){
|
|
|
- throw new Exception( 'Ambiguous use of `default()` found when matching for `'. $this->format($args) + '`' );
|
|
|
+ throw new Exception( 'Ambiguous use of `default()` found when matching for `' . $this->format($args) . '`' );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -8133,12 +8148,12 @@ class Less_Tree_Mixin_Call extends Less_Tree{
|
|
|
foreach($args as $a){
|
|
|
$argValue = '';
|
|
|
if( $a['name'] ){
|
|
|
- $argValue += $a['name']+':';
|
|
|
+ $argValue .= $a['name'] . ':';
|
|
|
}
|
|
|
if( is_object($a['value']) ){
|
|
|
- $argValue += $a['value']->toCSS();
|
|
|
+ $argValue .= $a['value']->toCSS();
|
|
|
}else{
|
|
|
- $argValue += '???';
|
|
|
+ $argValue .= '???';
|
|
|
}
|
|
|
$message[] = $argValue;
|
|
|
}
|
|
|
@@ -8851,7 +8866,7 @@ class Less_Visitor_processExtends extends Less_Visitor{
|
|
|
$selectorTwo = "{unable to calculate}";
|
|
|
}
|
|
|
|
|
|
- throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" + $selectorTwo+")");
|
|
|
+ throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:" . $selectorOne . ":extend(" . $selectorTwo . ")");
|
|
|
}
|
|
|
|
|
|
// now process the new extends on the existing rules so that we can handle a extending b extending c ectending d extending e...
|
|
|
@@ -9744,7 +9759,7 @@ class Less_Exception_Chunk extends Less_Exception_Parser{
|
|
|
}
|
|
|
}
|
|
|
if ($matched) { continue; }
|
|
|
- return $this->fail("unmatched `" + chr($cc) + "`", $currentChunkStartIndex);
|
|
|
+ return $this->fail("unmatched `" . chr($cc) . "`", $currentChunkStartIndex);
|
|
|
|
|
|
// /, check for comment
|
|
|
case 47:
|