blinkfox / hexo-theme-matery

A beautiful hexo blog theme with material design and responsive design.一个基于材料设计和响应式设计而成的全面、美观的Hexo主题。国内访问:http://blinkfox.com
https://blinkfox.github.io/
Apache License 2.0
5.23k stars 1.25k forks source link

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

Closed scutem closed 5 years ago

scutem commented 5 years ago

问题

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

重现

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

最后

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

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

chunchengwei commented 5 years ago

我按这个安装后,执行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 commented 5 years ago

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

chunchengwei commented 5 years ago

@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 commented 5 years ago

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

chunchengwei commented 5 years ago

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

chunchengwei commented 5 years ago

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

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

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

不清楚该怎么弄

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

blinkfox commented 5 years ago

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

chunchengwei commented 5 years ago

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

DBL2017 commented 4 years ago

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