-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
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 both library and engine interchangeably for the rest of the comment),
highlight:
engine: hljs|atom|prismNo 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:
engine: ...
hljs:
gutter: true
prism: ...highlight.hljs is preferred over highlight.highlight for clarity. But currently the option is used to address hexojs/hexo-util#19 (comment) using
highlight:
hljs: trueRetaining compatibility is possible (like #3675), i.e. can check highlight.hljs is a boolean or not. If boolean, parse it as highlight.hljs.classPrefix.
highlight:
hljs:
classPrefix: ''|'hljs-'Likewise, the approach could also apply to retain compatibility with the current options:
highlight:
auto_detect:
line_number:
tab_replace:
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