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) hex alpha color #3360

Closed
ierehon1905 opened this issue Oct 15, 2021 · 6 comments · Fixed by #3362
Closed

(CSS) hex alpha color #3360

ierehon1905 opened this issue Oct 15, 2021 · 6 comments · Fixed by #3362
Labels
enhancement An enhancement or new feature good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@ierehon1905
Copy link
Contributor

begin: '#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})'

Hello, thank you for your hard work. I noticed some issues with highlighting in css colors, specifically in those with alpha channel. According to MDN hex representation both short and long have optional alpha channel.

This breaks the highlighting giving the last symbols another color

@ierehon1905 ierehon1905 changed the title CSS hex alpha color (CSS) hex alpha color Oct 15, 2021
@joshgoebel
Copy link
Member

Ah should probably be {3,4} and {6,8} then... would you be willing to work on a PR?

@joshgoebel joshgoebel added enhancement An enhancement or new feature good first issue Should be easier for first time contributors help welcome Could use help from community language labels Oct 15, 2021
@taufik-nurrohman
Copy link
Member

taufik-nurrohman commented Oct 16, 2021

@ierehon1905 @joshgoebel

'#([0-9a-fA-F]{1,2}){3,4}'

Matches:

  • #cde
  • #cdef
  • #ccddee
  • #ccddeeff

@joshgoebel
Copy link
Member

Nice. If the security checker doesn't flag it because it can be resolved multiple ways... though the numbers might be low enough that it won't.

@ierehon1905
Copy link
Contributor Author

ierehon1905 commented Oct 16, 2021

#([0-9a-fA-F]{1,2}){3,4}

It seems like #f1f1f10 passes too, but it is not a valid color. Is this intended ?

@ierehon1905
Copy link
Contributor Author

ierehon1905 commented Oct 16, 2021

I have come up with a less pretty pattern.

#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b

regex 101 link

image

@ierehon1905
Copy link
Contributor Author

Created a pull request #3362

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature 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