Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stylus: Put the comment token behind the string token and set the greedy property to true #2372

Merged
merged 10 commits into from May 7, 2020

Conversation

dev-itsheng
Copy link
Contributor

After I solved the bug of comment which break the string and url, I also realized the comment can break the @namespace rule which named atrule-declaration token in Stylus tokenize. the grammar like this:

@namespace url(http://www.w3.org/1999/xhtml)
@namespace svg url(http://www.w3.org/2000/svg)

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 as variable-declaration, statement, property-declaration and selector (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 in property-declaration token.

Some extra change:

To match the comment in selector token, I added comment property in property.inside object.

To match the following comment, the greedy: true in comment should be set:

/*
comment
*/

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.

@dev-itsheng
Copy link
Contributor Author

I forgot to change the language in MDN, the English site is this.

@RunDevelopment
Copy link
Member

I have nothing to add. Really good fix!

Thank you for contributing @dev-itsheng!

quentinvernot pushed a commit to TankerHQ/prismjs that referenced this pull request Sep 11, 2020
…ismJS#2372)

Comments broke URLs in all non-greedy declarations. Comments are now matched as part of these declarations.
This also adds support for comments inside selectors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants