Stylus: Put the comment
token behind the string
token and set the greedy
property to true
#2372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After I solved the bug of comment which break the string and url, I also realized the comment can break the
@namespace
rule which namedatrule-declaration
token in Stylus tokenize. the grammar like this:So at first I try to add
greedy: true
in'atrule-declaration'
token, but I realized the same problem probably be happened in other tokens, such asvariable-declaration
,statement
,property-declaration
andselector
(In fact, I test them and the problems happened).We can certainly add
greedy: true
in every token, but I think there is a better solution, as the title says, is putting the token behind them.After that, I remove the
greedy: true
inproperty-declaration
token.Some extra change:
To match the comment in
selector
token, I addedcomment
property inproperty.inside
object.To match the following comment, the
greedy: true
incomment
should be set:Finally, about test:
To improve the changed code correctness, the tests of all scenes (all scenes which I can think about, there could be something that I ignore) are added.