SomMeri / less4j

Less language is an extension of css and less4j compiles it into regular css. Less adds several dynamic features into css: variables, expressions, nested rules, and so on. Less was designed to be compatible with css and any correct css file is also correct less file.
145 stars 47 forks source link

Rule with misplaced whitespace compiled before and fails now #306

Closed noullet closed 8 years ago

noullet commented 8 years ago

Hi,

I rely on an external LESS theme which contains a rule like that:

@line-height-computed: 20px;
pre {
      margin: 0 0( @line-height-computed / 2);
}

I assume that the whitespace should be located before the parenthesis, however it compiled fine with less4j-1.10.0 but does not compile with less4j-1.11.0 and above (because of the grammar refactoring?). Here is the error log:

java -jar less4j-1.11.0.jar test.less
Errors produced by compilation of test.less
ERROR 3:7 no viable alternative at input 'margin' in ruleset (which started at 2:1)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 3:7 no viable alternative at input 'margin' in ruleset (which started at 3:7)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 3:13 no viable alternative at input ':' in ruleset (which started at 3:13)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 3:15 no viable alternative at input '0' in ruleset (which started at 3:15)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 3:17 no viable alternative at input '0' in ruleset (which started at 3:17)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 3:18 no viable alternative at input '(' in ruleset (which started at 3:18)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 3:42 no viable alternative at input '/' in unknown ruleset (which started at 3:20)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 3:42 no viable alternative at input '/' in ruleset (which started at 3:42)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 3:45 no viable alternative at input ')' in ruleset (which started at 3:44)
 2: pre {
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

ERROR 4:1 missing EOF at '}' in stylesheet (which started at 1:1)
 3:       margin: 0 0( @line-height-computed / 2);
 4: }

Could not compile the file test.less

It compiles fine with less.js 2.5.3 and this difference is not documented here (unless I missed something): https://github.com/SomMeri/less4j/wiki/Differences-Between-Less.js-and-Less4j

The rule can be easily fixed but I assume that the change in less4j behavior is not intentional because it is not documented and diverges from less.js, hence the issue.

SomMeri commented 8 years ago

Thank you for reporting the error. This will be fixed in the next release, the bug got fixed along with #295. It had the same root cause as "math operation" problem mentioned there.

noullet commented 8 years ago

Thanks for your quick feedback and thanks for the fix.

Have a good day!

davydotcom commented 8 years ago

Just checking in on this blocked on a project. any ETA to next release? Want to push this out to less-asset-pipeline as soon as I can. Thanks

noullet commented 8 years ago

@davydotcom Funny to see you here, actually I got this error from less-asset-pipeline through less-grails-asset-pipeline (I am currently stuck with 2.1.0 because of that). Glad to know that you are eager to push the fix!

davydotcom commented 8 years ago

You can get around it by excluding less4j from the less asset pipeline dependency and addinf less4j 1.10.0 to your dependencied block On Oct 15, 2015 4:03 AM, "Nicolas Noullet" notifications@github.com wrote:

@davydotcom https://github.com/davydotcom Funny to see you here, actually I got this error from less-asset-pipeline through less-grails-asset-pipeline (I am currently stuck with 2.1.0 because of that). Glad to know that you are eager to push the fix!

— Reply to this email directly or view it on GitHub https://github.com/SomMeri/less4j/issues/306#issuecomment-148311875.

SomMeri commented 8 years ago

@davydotcom I will try to push it out, asap, within next few days. I originally through it would be released previous weekend.

I moved to new laptop and have to deal with unexpected problems (antlr3 does not work with java 8, maven-releas-plugin does not cooperate with newly installed maven, my old pgp key is not available for me now, and so on).

davydotcom commented 8 years ago

Np completely understand the troubles with maintaining libraries. This is a great plugin and sincerely appreciate the work put into it. Thanks for the update ill pass that along. On Oct 16, 2015 7:28 AM, "Mária Jurčovičová" notifications@github.com wrote:

@davydotcom https://github.com/davydotcom I will try to push it out, asap, within next few days. I originally through it would be released previous weekend.

I moved to new laptop and have to deal with unexpected problems (antlr3 does not work with java 8, maven-releas-plugin does not cooperate with newly installed maven, my old pgp key is not available for me now, and so on).

— Reply to this email directly or view it on GitHub https://github.com/SomMeri/less4j/issues/306#issuecomment-148689885.

SomMeri commented 8 years ago

@davydotcom Less4j 1.15.0 was just released. If you have a problem with that, let me know. Hopefully everything is setup now (and I should be able to solve problems where it is not) so next releases can be done with very little work.