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) Wrong highlight :first-of-type :first-child #3815

Open
zweroboy1 opened this issue Jul 5, 2023 · 8 comments · Fixed by #3853
Open

(css) Wrong highlight :first-of-type :first-child #3815

zweroboy1 opened this issue Jul 5, 2023 · 8 comments · Fixed by #3853
Labels
bug help welcome Could use help from community language

Comments

@zweroboy1
Copy link

Describe the issue
Wrong highlight :first-of-type :first-child, "-of-type" "-child" is not highlighted

Which language seems to have the issue?
CSS

Are you using highlight or highlightAuto?
highlightElement

Sample Code to Reproduce
chatGPT
hljs

Expected behavior
Correct highlighting :)

Additional context

@zweroboy1 zweroboy1 added bug help welcome Could use help from community language labels Jul 5, 2023
@joshgoebel
Copy link
Member

Please provide textual content of problematic example, not just an image.

@zweroboy1
Copy link
Author

For the CSS language, each letter in the pseudo-classes ":first-of-class" and ":first-child" should be colored. Currently, only ":first" is colored, while "-of-class" and "-child" remain the default color.

@joshgoebel
Copy link
Member

Yes, I understand, but please provide the RAW text (that you took a snap of) that I can easily copy and paste for testing.

@neix604
Copy link

neix604 commented Jul 13, 2023

There is the same problem here. "-of-type" and "-child" are not highlighted.
Even though I putted the tag name in front of the pseudo selector(like div:first-child), it wasn't solved.
I think this error occurs only in selectors that begin with ":first".

css_issue

The code is as follows.

:first-child { padding: 0; } :first-of-type { padding: 0; }

@joshgoebel
Copy link
Member

For use in "either" style regex the word lists need to be reverse-alpha sorted - which has the effect of putting the LONGEST terms first, preventing the shorter words from stealing the match. So simply reverse()ing the keyword lists might solve this. I think there are other examples.

@TimChinye
Copy link

TimChinye commented Apr 1, 2024

This has not been fixed.

See:
image
span:first-child {

Additionally, it doesn't recognise pseudo-elements that aren't pseudo-classes (which makes sense, but I'm not sure if it's on purpose):
image
span::first-child {

image
span::first-of-type {

It does work for some pseudo-classes & pseudo-elements:
image

@joshgoebel joshgoebel reopened this Apr 2, 2024
@Dxuian
Copy link
Contributor

Dxuian commented Sep 1, 2024

is this still open ?

@joshgoebel
Copy link
Member

yes appears so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help welcome Could use help from community language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants