-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ParseError for comments after rule name or in
@keyframes
This commit ports required logic from an upstream patch for Less.js 1.7: less/less.js@e045362c901e6bb5 This simply eats up comments and is easy to backport. Less.js 2.5.3 actually takes a different approach, it uses a ParserInput class and stores comments in a commentStore. This first change will allow the parser to eat up comments and prevent syntax errors. As we don't store the comments yet the generated CSS won't contain all comments because we have no way to re-inject those later, yet. The comments.css override allows us to make sure that we properly compile this Less without errors. The comments2.less tests comments between rule names and block definitions. Those are not only parsed properly, but also should be put in the generated CSS. What Less.js 2.0 does, they parse comments when handling spaces in skipWhitespace, instead of manually consuming comments in specific places during parsing, and comments are pushed to an array. Then, they either empty the comments array, or get the first one and add it to the output. In T353132 I'm going to do a follow-up on this work and match Less.js 2.0 implementation - introducing the ParserInput class with commentStore. As ParserInput change is going to affect overall parsing, I prefer to do it in a separate task. Bug: T353131 Change-Id: I95db673e90726909eaa108870ee600fa4eca351e
- Loading branch information
1 parent
0a022bd
commit a4411b4
Showing
3 changed files
with
104 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/******************\ | ||
* * | ||
* Comment Header * | ||
* * | ||
\******************/ | ||
/* | ||
Comment | ||
*/ | ||
/* | ||
* Comment Test | ||
* | ||
* - cloudhead (http://cloudhead.net) | ||
* | ||
*/ | ||
/* Colors | ||
* ------ | ||
* #EDF8FC (background blue) | ||
* #166C89 (darkest blue) | ||
* | ||
* Text: | ||
* #333 (standard text) // A comment within a comment! | ||
* #1F9EC9 (standard link) | ||
* | ||
*/ | ||
/* @group Variables | ||
------------------- */ | ||
#comments, | ||
.comments { | ||
/**/ | ||
color: red; | ||
/* A C-style comment */ | ||
/* A C-style comment */ | ||
background-color: orange; | ||
font-size: 12px; | ||
/* lost comment */ | ||
content: "content"; | ||
border: 1px solid black; | ||
padding: 0; | ||
margin: 2em; | ||
} | ||
/* commented out | ||
#more-comments { | ||
color: grey; | ||
} | ||
*/ | ||
.selector, | ||
.lots, | ||
.comments { | ||
color: grey, /* blue */ orange; | ||
-webkit-border-radius: 2px /* webkit only */; | ||
-moz-border-radius: 8px /* moz only with operation */; | ||
} | ||
.test { | ||
color: 1px; | ||
} | ||
.sr-only-focusable { | ||
clip: auto; | ||
} | ||
@-webkit-keyframes hover { | ||
0% { | ||
color: red; | ||
} | ||
} | ||
#last { | ||
color: blue; | ||
} | ||
/* */ | ||
/* { */ | ||
/* */ | ||
/* */ | ||
/* */ | ||
#div { | ||
color: #A33; | ||
} | ||
/* } */ | ||
/*by block */ | ||
#output-block { | ||
comment: /* // Not commented out // */; | ||
} | ||
/*comment on last line*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters