-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Feature request: support other syntax highlight libraries #4010
Comments
In order to retain backward compatibility for all current hexo theme, I suggest to remain current Prism related utility has been added in hexojs/hexo-util#168. Related code to be changed: |
During hexojs/hexo-util#168, I have noticed PrismJS is mainly designed for working at browser side. Many features likes "highlight specific lines", "The first line number" only work in browser. So if we are going to bring PrismJS to Hexo, IMHO we should address two options:
Also I have noticed something strange: When using Hexo, there are many ways to add syntax highlighted code to Hexo.
So it leads to a very strange result:
|
For PrismJS For PrismJS |
@hexojs/core @curbengh I have transferred this issue to Hexo repo. |
Here is a feature request about adding filter event for backtick code block: #1891 |
What about bring up an new API |
This will be a breaking change. Maybe we need to make prism highlight use the same API? #4119 |
I am considering about it. I still have no idea about how the API should be designed. |
This is a spin out of hexojs/hexo-util#19 (comment).
The idea is to support different libraries other than the current highlight.js, e.g.
A major benefit is that theme dev can use/adapt from much more css. Some library may also be faster than another. hexojs/hexo-util#39 can be addressed by atom and prism.
Currently, highlight.js is tightly integrated into hexo, so adding another library is expected not to be straightforward. One possible issue is configuration, which I think should be tackled first.
So, to change library, user can specify
engine
(I will refer bothlibrary
andengine
interchangeably for the rest of the comment),No problem, but here comes the tricky part, configuring each of them. While each engine may share similar options, I think ideally they should be separated, like so:
highlight.hljs
is preferred overhighlight.highlight
for clarity. But currently the option is used to address hexojs/hexo-util#19 (comment) usingRetaining compatibility is possible (like #3675), i.e. can check
highlight.hljs
is a boolean or not. If boolean, parse it ashighlight.hljs.classPrefix
.Likewise, the approach could also apply to retain compatibility with the current options:
However, I suggest not to retain old options forever, they can be dropped in hexo@5 for instance, and permanently move to under
highlight.hljs
.A side benefit of having hljs-specific option is that users familiar with the engine can use its option naming instead; hexo rename some option which confuse those users. See hexojs/hexo-util#40.
Previous suggestion #1300
The text was updated successfully, but these errors were encountered: