-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Theme Maint] Write up on changes for theme maintainers #3134
Comments
Would like to update my theme once the default theme is updated. I want to look around. |
Our default theme is pretty boring and doesn't really change much. I did just add |
I'll probably ping everyone after #3159 is merged and our first v11 beta is released. |
I really like the formatted metadata. There are some suggestions for it:
|
I'm not sure what you mean. When the theme maintainer makes changes, they bump it. Apart from that it requires no updates.
Git only tells me when the FILE was last changed, not when the theme itself was last changed. Many of themes have seen tons of commits, none related to THEME changes itself but rather just CSS maintenance, etc. I'm open to a better name for this.
Looks like clutter to me - perhaps I'm just used to the existing standard from all our language files which use undecorated comments.
I'm not opposed. I think for me maintainer and the name are the most important things here. |
CC @highlightjs/theme-maintainers Pinging this now as v11 is getting close to release. If any of you would like to improve your themes with support for all the new things, now is your chance. :) I should have already taken care of the more boring "busywork" stuff for you... ie, supporting both If you have any questions feel free to ask! |
Are |
See |
So, only is |
I'm not sure I understand what you are asking? /* BEFORE: Highlight.js v10 */
.hljs-function .hljs-title { }
/* AFTER: Highlight.js v11 */
.hljs-title.function_ { }
.hljs-title.function_.call__ { } But as already mentioned I believe I've taken care of this boing "maintenance" stuff already myself in many cases. |
@joshgoebel Your (very helpful) |
Correct. :) |
I'm going to use this issue to track items that theme maintainers may want to keep in mind when updating their themes for v11 and beyond. Each of the below items should be expanded into a brief explanation.
Overall Intention
Please skim #2500 and #2521 if you have time. The idea is higher fidelity highlighting and more nuanced highlighted (when possible). Often there are things we could easily highlight but we have chosen not to in the past (operators, punctuation, properties, function dispatch, etc)... we'd like to start highlighting those things going forward when it makes sense to do so.
We're also open to feedback on these things as there is still wiggle room in the v11 window on how some of these things will land. (particularly exactly how the new tiered scopes shake out)
Newer scopes
We've recently added:
property
punctuation
operator
variable.language
title.function
title.class
title.class.inherited
char.escape
You can see GitHub itself highlighting the operator and properties.
Please see our CSS Class reference. This is part of our higher fidelity goals. A theme that highlights these items should feel more "complete". If your theme purposely choses to opt-out you should provide an empty rule so our theme checker knows you purposely don't want to highlight these. Example:
Do not worry about any wasted space - these things will be minified/stripped at build time.
New tiered scopes
To add more nuance (#2521) we have added tiered scopes. For things that are pure renamings the core team can handle those... such as say if we decided to rename
meta-keyword
tometa.keyword
. But sometimes the changes are a bit broader. This allows for more nuance in parsing (and possibly also more nuance in coloring).Instead of just a
string
in the future we might easily have:string.unquoted
string.quoted
string.quoted.triple
If you've worked with TextMate grammars this should be immediately familiar.
A theme can provide coloring for just
string
at the top-level or it could get as nuanced as it wants. Note: It will of course take time for grammars to support this additional nuance and there will be some discovery on how much nuance is good to have. This is why I say themes may require some degree of "maintenance" as time goes on.Deprecation of
class
andfunction
for indicating definitionsAccording to our docs these are support to be used fo class and function definitions... but they have been used (and abused) rather inconsistently so they are being deprecated in core.
This can result in some themes & grammar combos looking funny and large swaths of unintended highlighting. Going forward it's recommended that
class
andfunction
simply not be highlighted at the top-level. And the recommendation for grammars is that they not emit these top-level scopes at all.This should be fine for v10 support as well. Grammars using
function
to indicate a function name are considered broken and should instead by updated.Deprecation of
class > title
andfunction > title
for titlesWe're trying to simplify grammars where possible to be flatter... where-as before you may have had a nested scope... now you would instead have a flatter tree but with parts of the match have tiered scopes. Often then can significantly reduce the complexity of a grammar, but with exactly or almost the same fidelity of highlighting.
Before (note the "class" class wrapping the whole start of the class):
Which you might have targeted with the selector
.hljs-class .hljs-title
.In the future (no wrapper):
Which you would target with a
.hljs-title.class_
selector.Supporting v10 and v11 simultaneously.
Generally that simply means supporting old and new scope selectors. This is desirable for the immediate future, perhaps until v12.
Note the single underscore
_
infunction_
and the double incall__
. Please see our CSS Class reference for documentation on how tiered scopes work.Adding metadata.
Theme meta-data should lead the CSS and look something like:
At a minimum the following should be provided:
Theme:
Author:
if knownMaintainer:
Website:
(if there is a canonical source of the theme elsewhere)Updated:
Sample:
The new
./tools/checkTheme
utility.Our new theme checked can tell you what your theme might be missing. You simply pass the filename of a theme to it. This tool is brand new and likely to improve with time.
Example:
The text was updated successfully, but these errors were encountered: