大家有没有在用 hexo 的时候遇到在正文中对“{{任何内容}}”解析不正常的问题,我因为经常写数学公式,所以经常会碰到这种问题, 目前唯一的解决办法就是 escape bracket,需要在每一对花括号加{% raw %}这种方式,一旦公式增多一个一个加又太麻烦,大家有什么解决方案? 最近在考虑用 hugo 替换基于 nodejs 的 hexo,但是 hugo 的主题基本上没有想 next 那么完善的,不是缺这个就是少那个…
产生错误
正确执行:
1
MonoLogueChi 2018-11-21 22:23:43 +08:00 via Android
用的什么渲染组件,装了哪些插件,主题用的是什么,这些都用影响到
|
![]() |
2
niuxuewei OP @MonoLogueChi hexo-renderer-pandoc
这个好像是跟 hexo 有关 |
![]() |
3
stebest 2018-11-21 23:02:39 +08:00
hexo 不是有 mathjax 插件写公式么
|
![]() |
4
mathzhaoliang 2018-11-21 23:08:55 +08:00
hexo 默认的 markdown 渲染器是 hexo-renderer-marked,会先按照 markdown 语法解析,然后才是 latex,所以会有冲突。换成 hexo-renderer-pandoc,然后安装 pandoc 就行。
|
![]() |
5
rabbbit 2018-11-21 23:26:34 +08:00
试试这个,记得装之前备份,因为要卸掉默认的渲染器
https://github.com/CHENXCHEN/hexo-renderer-markdown-it-plus |
![]() |
6
niuxuewei OP @stebest 数学公式没问题 但是遇到这样的$\sqrt{{x^2}+{y^2}}$ 再使用 hexo g 就会出现解析错误 原因是 hexo 会把{{*}}当作变量解析…
|
![]() |
7
niuxuewei OP @mathzhaoliang 冲突问题已经通过 pandoc 解决了 可以参见上一条回复
|
![]() |
9
mathzhaoliang 2018-11-22 08:22:35 +08:00
@niuxuewei 你是想输出什么?内层的 {} 表示求小数部分吗?
|
![]() |
10
niuxuewei OP @mathzhaoliang 我想输出数学公式用 latex 语法 比如 $\sqrt{{x^2}+{y^2}}$ 这是根号下 x 方+y 方 你可以试试把这个代码加在你的正文里 然后用 hexo g 生成就会报错
|
![]() |
11
niuxuewei OP @mathzhaoliang 可以参见这个截图 
|
![]() |
12
niuxuewei OP @mathzhaoliang 如果去掉把{{}}消去 就可以解决这个问题
或者加入 escape bracket 类似这样 |
![]() |
13
mathzhaoliang 2018-11-22 11:49:34 +08:00
@niuxuewei 所以不是 hexo 的问题,是你的输入不对。
|
![]() |
14
FEDT 2018-11-22 11:57:02 +08:00 via iPhone
遇到过。。没想到现在还没解决
|
![]() |
16
no1xsyzy 2018-11-22 13:11:12 +08:00 ![]() 没接触过,但试试这个?
$\sqrt{ {x^2}+{y^2} }$ |
![]() |
17
no1xsyzy 2018-11-22 13:12:10 +08:00
|
![]() |
19
niuxuewei OP @no1xsyzy 我测试只需要破坏前面的{{就行,后面的}}可以保留,像这样$\sqrt{ {x^2}+{y^2}}$,回头可以写一个 py 脚本自动化解决这个问题
|