Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Feature request: support other syntax highlight libraries #4010
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.
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
highlight: engine: hljs|atom|prism
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: engine: ... hljs: gutter: true prism: ...
highlight: hljs: true
Retaining compatibility is possible (like #3675), i.e. can check
highlight: hljs: classPrefix: ''|'hljs-'
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
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
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: