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

(CSS) :before/:after are not highlighted correctly #3240

Closed
LunarTwilight opened this issue Jun 14, 2021 · 2 comments · Fixed by #3358
Closed

(CSS) :before/:after are not highlighted correctly #3240

LunarTwilight opened this issue Jun 14, 2021 · 2 comments · Fixed by #3358
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@LunarTwilight
Copy link

LunarTwilight commented Jun 14, 2021

Describe the issue: :before/:after are not highlighted correctly.

Which language seems to have the issue?: CSS

Are you using highlight or highlightAuto?: highlightAll

...

Sample Code to Reproduce:

.test:before,
.test:after {
  color: pink;
  border-color: red;
}

https://jsfiddle.net/1tfr2cow/

Expected behavior: :before/:after are highlighted like ::before/::after

Additional context: https://developer.mozilla.org/en-US/docs/Web/CSS/::before

@LunarTwilight LunarTwilight added bug help welcome Could use help from community language labels Jun 14, 2021
@joshgoebel
Copy link
Member

Note: Any PR here would also need to update css_consistency and ensure consistent behavior across all 4 of our CSS superset grammars. See tools/css.

I suppose if need be we could add another rule that matches all pseudo elements as if they were pseudo-classes... that doesn't excite me (CSS2 is older than other things that we've removed from other languages as they have evolved over the years - so I think an argument could be made this simply isn't that important). Is CSS exceptional somehow? I have a feeling CSS2 will still be around in 20 years just because of the nature of the web - but will still highlighting it properly be important then? If we find some weird thing from CSS1 or CSS0.9 that browsers still support, should we add it?

That said, I wouldn't block this addition (I'm assuming it would be simple) but the distinction between pseudo classes and elements should remain (as they are different things) and if CSS2 specific support is added it should be additive, not blurring (or in any way making worse) our current quite proper support of CSS3.


One other idea here (if we don't fix CSS2 explicitly) is to consider just resolving the breakage... an attribute following an unknown psuedo-selector shouldn't break our highlighting - whether or not we support CSS2. That change might be as simple as adding { to the CSS : rule's stop regex.

@zsoltlengyelit
Copy link
Contributor

@joshgoebel you can assign the issue to me now. See PR: #3358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants