-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add possibility to use predefined highlight.js themes #3
Comments
I'm not sure whether this is possible. For example, it's my understanding that the color red would not be the one defined in a highlight.js style-sheet, but from the Terminal's colours. There might still be little benefit in supporting highlight.js, since logic-wise they often differ from each other. However, they wouldn't use the colours you'd expect them to. |
@idleberg is correct. Themes would work for some terminals that support all colors, but not all colors will work in all terminals. Even so, we could make the themes works for those who did have them available. I'm not sure I can take this on right now, but I can assist if someone wants to work on a PR together. |
Actuall, it should work in terminals that support true color. The Rust app |
If someone submits a pr with the option for 1) using true color when supported, and 2) mapping highlight js css colors and providing a way to make this extension, I'll review and update the package. It's a good request. |
I've been looking into it and the real question to me is how to treat fallbacks. The easiest would be to fall back to the defaults that are currently defined in Here are some questions that came up:
|
Good questions. I originally based this on terminal color names, not really thinking about existing theme's, as there are places in which you just can't control the colors, (like some cloud server you can't update the machine image), it didn't make sense to try and control colors at that level. You can check for the presence of various color support with some of sindresorhus's modules I believe, so you could switch behavior based on colors available to term, plus a true color flag passed into opts. I'm not sure if it's possible to query the exact colors a terminal uses, so I don't think you could do a conversation algorithm to get to the closest colors. You could assume that if you pass in a css Theme, that it will use true colors if the term supports true colors. That might work, and be least confusing. I would see line numbers, etc as being a separate setting. |
I was thinking about using supports-color: if (supportsColor.stderr.has16m) {
// Parse CSS theme
// Apply colors from CSS using chalk
} In fact I've just started on a parser for Highlight.js themes, should be easy to integrate.
This is interesting, but I didn't even think that far. Maybe a nice to have for later? By the way, if this works out and people like it, we could also support Base16 themes. There will probably be less trouble (or none) with fallback options. |
Since this library is using
highlight.js
, it would be cool to be able to use its themes out of the box.The text was updated successfully, but these errors were encountered: