Hexo报错-highlight相关
Hexo报错-highlight相关
hexo g -d的时候报以下错误
1 | Deprecated as of 10.7.0. highlight(lang, code, ...args) has been deprecated. |
问题原因
旧版的hexo-util模块中,使用了
1 | result = hljs.highlight(lang, lines.shift(), false, result.top); |
而在highlight更新后,相对应的语法变成了
1 | result = hljs.highlight(lines.shift(), { |
解决办法
方法一
在node_modules/hexo-util/lib/highlight.js 文件中修改上述代码
方法二
由于Propose: Improve highlight API · Issue #2277 · highlightjs/highlight.js (github.com)已经解决了该问题,因此只需更新hexo-util模块
1 | npm i hexo-util |
参考资料
- highlight(lang, code, …args) has been deprecated. · Issue #245 · hexojs/hexo-util (github.com)
- Deprecated as of 10.7.0. highlight(lang, code, …args) has been deprecated. Deprecated as of 10.7.0. Please use highlight(code, options) instead. · Issue #4672 · hexojs/hexo (github.com)
- Hexo 与 Next 版本升级教程 | Clay 的技术博客 (techgrow.cn)
- Propose: Improve
highlightAPI · Issue #2277 · highlightjs/highlight.js (github.com)
Comment





