diff --git a/src/com/inet/lib/less/CssFormatter.java b/src/com/inet/lib/less/CssFormatter.java index afd2cd2c..85eeb300 100644 --- a/src/com/inet/lib/less/CssFormatter.java +++ b/src/com/inet/lib/less/CssFormatter.java @@ -759,11 +759,7 @@ void appendProperty( @Nonnull String name, @Nonnull Expression value ) { name = SelectorUtils.replacePlaceHolder( this, name, value ); output.append( name ).append( ':' ); space(); - if( "font".equals( name ) && value.getClass() == Operation.class ) { - appendFontPropertyValue( (Operation)value ); - } else { - value.appendTo( this ); - } + value.appendTo( this ); if( state.importantCount > 0 || value.isImportant() ) { output.append( " !important" ); } @@ -771,32 +767,6 @@ void appendProperty( @Nonnull String name, @Nonnull Expression value ) { newline(); } - /** - * Special hack for property "font" which contains a value font-size/line-height - * @param value the value - */ - void appendFontPropertyValue( Operation value ) { - ArrayList operands = value.getOperands(); - char operator = value.getOperator(); - switch( operator ) { - case '~': - case ',': - value.appendTo( this ); - return; - } - for( int i = 0; i < operands.size(); i++ ) { - if( i > 0 ) { - this.append( operator ); - } - Expression operand = operands.get( i ); - if( operand.getClass() == Operation.class ) { - appendFontPropertyValue( (Operation)operand ); - } else { - operand.appendTo( this ); - } - } - } - /** * Increment the important flag. */ diff --git a/src/com/inet/lib/less/LessParser.java b/src/com/inet/lib/less/LessParser.java index b7165af7..8263b660 100644 --- a/src/com/inet/lib/less/LessParser.java +++ b/src/com/inet/lib/less/LessParser.java @@ -45,6 +45,10 @@ */ class LessParser implements FormattableContainer { + private boolean strictMath; + + private int nesting; + private URL baseURL; private ReaderFactory readerFactory; @@ -184,7 +188,9 @@ private void parseSemicolon( FormattableContainer currentRule ) { continue LOOP; } String name = trim( builder ); + strictMath = "font".equals( name ); Expression value = parseExpression( (char)0 ); + strictMath = false; ch = read(); switch( ch ) { case '}': //last line in a block does not need a semicolon @@ -784,6 +790,14 @@ private Expression parseExpression( char leftOperator ) { } switch( ch ) { case '/': + if( strictMath && nesting == 0 ) { + if( wasWhite ) { + builder.append( ' ' ); + wasWhite = false; + } + builder.append( ch ); + continue LOOP; + } if( comment( null ) ) { continue LOOP; } @@ -979,7 +993,9 @@ Operation parseParameterList() { Expression left = null; char ch; do { + nesting++; Expression expr = parseExpression( (char)0 ); + nesting--; left = concat( left, ';', expr ); ch = read(); } while( ch == ';' ); diff --git a/test/com/inet/lib/less/samples/general/import.css b/test/com/inet/lib/less/samples/general/import.css index f7c93d22..46ade3a4 100644 --- a/test/com/inet/lib/less/samples/general/import.css +++ b/test/com/inet/lib/less/samples/general/import.css @@ -9,6 +9,7 @@ f: a / b; g: a / b; h: a / b; + font: 3/2; } .values .slash2 { background: url("img.jpg") center / 100px; diff --git a/test/com/inet/lib/less/samples/general/importOptional.css b/test/com/inet/lib/less/samples/general/importOptional.css index b3bba7f6..6995c342 100644 --- a/test/com/inet/lib/less/samples/general/importOptional.css +++ b/test/com/inet/lib/less/samples/general/importOptional.css @@ -5,6 +5,7 @@ f: a / b; g: a / b; h: a / b; + font: 3/2; } .slash2 { background: url("img.jpg") center / 100px; diff --git a/test/com/inet/lib/less/samples/general/slash.css b/test/com/inet/lib/less/samples/general/slash.css index b3bba7f6..6995c342 100644 --- a/test/com/inet/lib/less/samples/general/slash.css +++ b/test/com/inet/lib/less/samples/general/slash.css @@ -5,6 +5,7 @@ f: a / b; g: a / b; h: a / b; + font: 3/2; } .slash2 { background: url("img.jpg") center / 100px; diff --git a/test/com/inet/lib/less/samples/general/slash.less b/test/com/inet/lib/less/samples/general/slash.less index 463c71b1..8d12b418 100644 --- a/test/com/inet/lib/less/samples/general/slash.less +++ b/test/com/inet/lib/less/samples/general/slash.less @@ -7,6 +7,7 @@ f: a/ b; g: a /b; h: a/b; + font:3/2; } .slash2 { background: url("img.jpg") center / 100px; diff --git a/test/com/inet/lib/less/samples/less_org_tests/less/css.css b/test/com/inet/lib/less/samples/less_org_tests/less/css.css index efb17e86..ab01bd05 100644 --- a/test/com/inet/lib/less/samples/less_org_tests/less/css.css +++ b/test/com/inet/lib/less/samples/less_org_tests/less/css.css @@ -60,7 +60,7 @@ p + h1 { #more-shorthands { margin: 0; padding: 1px 0 2px 0; - font: normal small / 20px 'Trebuchet MS', Verdana, sans-serif; + font: normal small/20px 'Trebuchet MS', Verdana, sans-serif; font: 0/0 a; border-radius: 0.5px; }