Skip to content
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

关于 hexo-renderer-kramed 插件导致语法高亮失效的问题。 #23

Closed
scutem opened this issue Oct 22, 2018 · 9 comments
Closed

Comments

@scutem
Copy link

scutem commented Oct 22, 2018

问题

按照这里的说明添加了mathjax 的支持后,发现语法高亮莫名失效了。

重现

排查后发现,执行语句
$ npm uninstall hexo-renderer-marked --save
$ npm install hexo-renderer-kramed --save
hexo-renderer-marked 换成 hexo-renderer-kramed 后导致语法高亮失效。
并且问题同样出现在 landscape 主题中。

最后

hexo-renderer-kramed 作者已经匿了。。目前尝试了不少方案,都有大大小小的问题。
给需要添加 mathjax 的人提个醒。

要是有针对 hexo-theme-matery 主题有好的解决方案求告知

@chunchengwei
Copy link
Contributor

chunchengwei commented Dec 1, 2018

我按这个安装后,执行hexo g时报错

41 ERROR Invalid or unexpected token in "/hexo/themes/hexo-theme-matery/layout/archive.ejs"
42 SyntaxError: Invalid or unexpected token in "/hexo/themes/hexo-theme-matery/layout/archive.ejs"
43 at new Function ()
44 at exports.compile (/hexo/node_modules/hexo-renderer-mathjax/node_modules/ejs/lib/ejs.js:242:14)
45 at Object.exports.render (/hexo/node_modules/hexo-renderer-mathjax/node_modules/ejs/lib/ejs.js:284:66)
46 at Hexo. (/hexo/node_modules/hexo-renderer-mathjax/index.js:14:24)
47 at Hexo.tryCatcher (/hexo/node_modules/bluebird/js/release/util.js:16:23)
48 at Hexo.ret (eval at makeNodePromisifiedEval (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promisify.js:184:12), :13:39)
49 at Promise.then.text (/hexo/node_modules/hexo/lib/hexo/render.js:61:21)
50 at tryCatcher (/hexo/node_modules/bluebird/js/release/util.js:16:23)
51 at Promise._settlePromiseFromHandler (/hexo/node_modules/bluebird/js/release/promise.js:512:31)
52 at Promise._settlePromise (/hexo/node_modules/bluebird/js/release/promise.js:569:18)
53 at Promise._settlePromiseCtx (/hexo/node_modules/bluebird/js/release/promise.js:606:10)
54 at _drainQueueStep (/hexo/node_modules/bluebird/js/release/async.js:142:12)
55 at _drainQueue (/hexo/node_modules/bluebird/js/release/async.js:131:9)
56 at Async._drainQueues (/hexo/node_modules/bluebird/js/release/async.js:147:5)
57 at Immediate.Async.drainQueues [as _onImmediate] (/hexo/node_modules/bluebird/js/release/async.js:17:14)
58 at runCallback (timers.js:705:18)
59 at tryOnImmediate (timers.js:676:5)
60 at processImmediate (timers.js:658:5)

@blinkfox
Copy link
Owner

blinkfox commented Dec 2, 2018

@scutem @chunchengwei 你们参考下这篇文章中关于数学公式的解决方案试试,应该可以解决一些,数学公式这个主要是Hexo的Markdown解析器与MathJax有冲突引起的,没啥好的办法。

@chunchengwei
Copy link
Contributor

chunchengwei commented Dec 3, 2018

@blinkfox 辛苦辛苦,我看你刚更新了代码 说加入了 mathjax,可否把说明也更新一下,不知道是否需要把 hexo-renderer-marked 换成 hexo-renderer-kramed 。我最近按照别的模板 通过加mathjax.ejs的方法也支持了mathjax但由于把 hexo-renderer-marked 换成 hexo-renderer-kramed,同样遇到了代码不高亮的问题。

我参考的代码是:
https://github.com/litten/hexo-theme-yilia/blob/master/layout/_partial/mathjax.ejs

@blinkfox
Copy link
Owner

blinkfox commented Dec 4, 2018

晚上回去更新吧,也还没有推到master里面,只是加了MathJax的支持,大部分情况下的数学公式是没问题的.如果公式里面有下划线_之类的,公司显示的就不一定对,因为两者的语法冲突只能通过引擎层面去解决了。

@chunchengwei
Copy link
Contributor

@blinkfox 已经pull下来了,很好用。

@chunchengwei
Copy link
Contributor

@blinkfox 显示markdown的table时出现问题,

错误可以参见这里,而且该文档没有开启mathjax:
Java笔记

这里有人讨论过这个:
支持latex加载table出现问题

不清楚该怎么弄

晚上回去更新吧,也还没有推到master里面,只是加了MathJax的支持,大部分情况下的数学公式是没问题的.如果公式里面有下划线_之类的,公司显示的就不一定对,因为两者的语法冲突只能通过引擎层面去解决了。

@blinkfox
Copy link
Owner

blinkfox commented Dec 4, 2018

@chunchengweiMathJax没关系,没开启MathJax的话,页面就不会有MathJax相关的元素,因该是你的table写法有问题吧,为啥你下面那个table就没问题呢

@chunchengwei
Copy link
Contributor

@blinkfox 确实是我的问题,在哪里整个表格向右缩进了一下,我把缩进去掉就没问题了。但是这个在本地用typora打开是没问题的可以正常显示。但是这里不行。不过确实不是主题的问题。我使用其他的主题试了一下也是这样。

@DBL2017
Copy link

DBL2017 commented Apr 17, 2020

为了功能正常,我已经放弃代码高亮了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants