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
enh(css-like) custom attributes should highlight as attr
, including the --
#3237
Comments
Any patch here would need to keep in mind #2269 and provide patches for ALL 4 grammars potentially or explain clearly why this does not apply to some (I'm not sure if it does or not). A patch that only fixes just CSS would not be accepted. I'm not sure what to do here is so clear cut though. This reminds me a little of our refusal to highlight vendor prefixes, which I have argued is actually a feature, not a bug. There are a few different things to consider here:
While Github's choices are interesting I don't want to fall into the trap that it's somehow "canonical" or that we always must do the same thing just because they (or anyone else) does. @allejo Thoughts? |
Hey @joshgoebel, each one of these grammars, have their own syntax for defining variables. My example is explicit for the
I would say yes.
I don't think so. Do you think it would make sense to open a PR as a proposal? I would really like to contribute to |
I'm not talking about custom variable systems that have been "bolted on". Most (all?) of these are (or allow) super-sets of CSS, ie they allow basic CSS without using any of the advanced features. In those cases simple CSS should highlight exactly the same across all 4 grammars when it's simple CSS. This has been all over the map in the past and a lot of work has been done to bring this back in line... So when considering any changes to basic CSS all grammars that are supersets of CSS must ALSO be dealt with simultaneously. |
Isn't that exactly what your PR does though? I'm confused. |
I don't have strong opinions on this but technically it's not part of the variable name though... it's more "syntactic sugar" for declaring that an attribute is a variable vs a CSS attribute. But I suppose if we highlight |
According to MDN docs, it sounds to me like Considering that these are "custom properties", they're no different from any other CSS property. So I think they should be highlighted with the same class name and have an additional class like |
Yes you right, and that's because I would get weird highlighting behavior otherwise. Here is an example of not handling the It seems a bit off. What do you think guys? My PR addresses this on these lines: highlight.js/src/languages/css.js Lines 115 to 118 in 76da024
|
Thanks for bringing some much needed clarity. :-)
Agree, but it's really an
Well, different in that they have no semantic meaning on their own, which per our our guidelines makes them
I don't see how this is needed since this is already covered with the distinction between
That is an entirely separate problem. To avoid that we can match it with a rule - but that doesn't mean we must give it a scope or highlight it any special way. main {
color: var(--color); Now at this point we have a custom property being used as a variable... You could make the argument to apply |
Since So what I think needs to happen here:
|
attr
, including the --
Closing with PR closing. |
Hello and thanks for this amazing library! I am using it for my blog to highlight code snippets, and recently I used CSS highlighting on a code example which included CSS variables.
More specifically I have this case:
The output looks like this:
Normally, I would expect that the prefixing
--
of the variables would have been handled as part of the attribute.I am thinking of forking this repo to introduce a PR addressing this issue. What do you think?
The text was updated successfully, but these errors were encountered: