-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Custom Class: New class adder feature #2075
Custom Class: New class adder feature #2075
Conversation
Looks promising! |
My apologies–could you remind me what sparked this PR? |
The idea was some people want to selectively highlight certain tokens differently from what we do. In the above example (which was pre #2073), the colon The main purpose is to give the designers of themes more freedom, so they aren't limited to the way we choose to tokenize. Of course, you can also achieve this by modifying the grammar but that's a lot harder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API change is def necessary cuz content
is probs the least useful aspect to add additional classes. Alternatively, we could pass it in as an object with the three properties, which would eliminate the question of what order to make them.
Also, regarding the API: |
Yeah, it kinda feels like |
No, because:
|
Ok... maybe it makes more sense for |
Sounds good, but this won't make |
Yeah, I don't think that's a necessary goal at this point. At least this makes the behavior consistent. |
Sorry for the late responses. I've been a little busy lately. The only things stopping v1.18 are #1998 and #2074. TBH, #2074 modifies Core and isn't as important as #1998, so I'm fine with leaving it out of this release if it'll mean that we can release faster. I'll do the changelog in the meantime. |
This adds a function to let the user define custom classes for specific tokens. Example:
(You can also define multiple such functions.)
The whole thing is implemented via the
wrap
hook, socontent
is the innerHTML of the token. I choose this overbefore-tokenize
because for users innerHTML is easier to understand than the Prism token stream.Further considerations
This feature is kind of a superset of Highlight keywords.
So maybe we could
combine the twoedit: merge HK into CC deprecate HK?@MattMcFarland I hope this helps.