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

<MathJax>可以实现行内代码不能实现行间代码! #826

Closed
veya2ztn opened this Issue Apr 13, 2016 · 20 comments

Comments

Projects
None yet
@veya2ztn

veya2ztn commented Apr 13, 2016

Expected behavior (预期行为)

下述代码包含了MathJax在行间的使用$$ $$和行内的使用$ $

### Mathtype in List
+ Transverse Ising model
  $$
  H=-\sum_{i=1}^N (\sigma_{i}^x \sigma_{i+1}^x+g \sigma_{i}^z)
  $$
###Mathtype between lines
$$
H=-\sum_{i=1}^N (\sigma_i^x \sigma_{i+1}^x+g \sigma_i^z)
$$
### Mathtype inline in list
+ the particle has only two state $\left| \uparrow \right\rangle$ and $\left| \downarrow \right\rangle$, which means that $\sigma^z \left| \uparrow \right\rangle =1 \left| \uparrow \right\rangle$

预期的行为应当是

Actual behavior (实际行为)

Steps to reproduce the behavior (重现步骤)

NexT Informations

Add the ✔ sign before an item which is affected by this behavior.

NexT Version:

✔ Master

  • Latest Release
  • Old version -

NexT Scheme:

  • All schemes
  • Muse
    ✔ Mist
  • Pisces

Other Informations (Like Browser, System, Screenshots)

不仅仅是不能显示的问题,即使是显示代码 ,在很多代码里面都产生了_符号的丢失,比如\sigma_i变成了\sigmai, c_i变成 ci 我查了一下生成的网页的html代码 发现c_i 被标签<em>i</em> c所替代 不知道怎么回事

@veya2ztn

This comment has been minimized.

Show comment
Hide comment
@veya2ztn

veya2ztn Apr 13, 2016

系统是windows
我也测试了除了next以外的其他theme
同样发现这个现象,所以这似乎是hexo的通病?

veya2ztn commented Apr 13, 2016

系统是windows
我也测试了除了next以外的其他theme
同样发现这个现象,所以这似乎是hexo的通病?

@tangbotony

This comment has been minimized.

Show comment
Hide comment
@tangbotony

tangbotony Apr 17, 2016

凡是\sum_{i=1}^n这种句子,都需要写成sum_i^n,不能再加括号{}了,然后在后面说明i的取值范围就行,不要问我怎么知道的,我一个一个测试的,弄了好久,都是泪啊。。。。可以看看我弄的这个:http://forwell.me/2016/04/15/basic-knowledge-about-probability/

tangbotony commented Apr 17, 2016

凡是\sum_{i=1}^n这种句子,都需要写成sum_i^n,不能再加括号{}了,然后在后面说明i的取值范围就行,不要问我怎么知道的,我一个一个测试的,弄了好久,都是泪啊。。。。可以看看我弄的这个:http://forwell.me/2016/04/15/basic-knowledge-about-probability/

@veya2ztn

This comment has been minimized.

Show comment
Hide comment
@veya2ztn

veya2ztn Apr 18, 2016

@tangbotony 额 谢谢。
但是问题似乎不仅仅在于\sum_i 变成了 \sumi
还有在求和内部的 \sigma_i 变成了 \sigmai
以及,我看着你弄的网页 数学代码处理的很好 和我写的有什么不同?

veya2ztn commented Apr 18, 2016

@tangbotony 额 谢谢。
但是问题似乎不仅仅在于\sum_i 变成了 \sumi
还有在求和内部的 \sigma_i 变成了 \sigmai
以及,我看着你弄的网页 数学代码处理的很好 和我写的有什么不同?

@tangbotony

This comment has been minimized.

Show comment
Hide comment
@tangbotony

tangbotony Apr 19, 2016

@veya2ztn ,建议你写latex的时候,直接在线写,边写边测试,这样的话就能够知道怎么写对,怎么写不对了...Hexo对公式的处理非常的不好,我就是一边写一边看网站的显示的,所以知道怎么写网站能够显示正常,怎么写网站显示不正常。
目前我就知道凡是\sum_{i=1}^n这种句子,都需要写成sum_i^n
同一个latex语句里面不能出现多个等号,否则就无法显示,所以我最后的那个公式分成了三部分显示。
5fe3df15-e459-48a0-bc2d-d2ce1253647d

tangbotony commented Apr 19, 2016

@veya2ztn ,建议你写latex的时候,直接在线写,边写边测试,这样的话就能够知道怎么写对,怎么写不对了...Hexo对公式的处理非常的不好,我就是一边写一边看网站的显示的,所以知道怎么写网站能够显示正常,怎么写网站显示不正常。
目前我就知道凡是\sum_{i=1}^n这种句子,都需要写成sum_i^n
同一个latex语句里面不能出现多个等号,否则就无法显示,所以我最后的那个公式分成了三部分显示。
5fe3df15-e459-48a0-bc2d-d2ce1253647d

@iissnan

This comment has been minimized.

Show comment
Hide comment
@iissnan

iissnan May 5, 2016

Owner

我不太清楚 MathJax,是否跟 MathJax 的配置有关系,NexT 目前使用的是:

MathJax.Hub.Config({
      tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });

inlineMath 的设定是否有关联?
@veya2ztn @tangbotony

Owner

iissnan commented May 5, 2016

我不太清楚 MathJax,是否跟 MathJax 的配置有关系,NexT 目前使用的是:

MathJax.Hub.Config({
      tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });

inlineMath 的设定是否有关联?
@veya2ztn @tangbotony

@seisman

This comment has been minimized.

Show comment
Hide comment
@seisman

seisman May 13, 2016

Contributor

遇到了同样的问题。根据 hexojs/hexo#524 的说法,是hexo默认的marked的问题。目前的解决办法是换用 hexo-renderer-pandoc

Contributor

seisman commented May 13, 2016

遇到了同样的问题。根据 hexojs/hexo#524 的说法,是hexo默认的marked的问题。目前的解决办法是换用 hexo-renderer-pandoc

@veya2ztn

This comment has been minimized.

Show comment
Hide comment
@veya2ztn

veya2ztn May 15, 2016

@tangbotony @iissnan @seisman @Vinnl @earthday 我找到一个方法,在所有的 _ 前加 \ 就正常了。我想问一下能否用js在markdown渲染之前把所有$$...$$内部的 _ 前面全部加一个 \ ?

veya2ztn commented May 15, 2016

@tangbotony @iissnan @seisman @Vinnl @earthday 我找到一个方法,在所有的 _ 前加 \ 就正常了。我想问一下能否用js在markdown渲染之前把所有$$...$$内部的 _ 前面全部加一个 \ ?

@veya2ztn

This comment has been minimized.

Show comment
Hide comment
@veya2ztn

veya2ztn May 15, 2016

或者用 {% math %}\begin{aligned}.............\end{aligned}{% endmath %} 来代替$$..........$$

veya2ztn commented May 15, 2016

或者用 {% math %}\begin{aligned}.............\end{aligned}{% endmath %} 来代替$$..........$$

@veya2ztn

This comment has been minimized.

Show comment
Hide comment
@veya2ztn

veya2ztn May 17, 2016

@tangbotony @iissnan @seisman @Vinnl @earthday 我想我已经完美解决这个问题了 如我所说,可以用js在markdown渲染前将所有的$$..$$替换成 {% math %}\begin{aligned}.............\end{aligned}{% endmath %}
方法如下
在你所写的.md文本的正文最后加入下面这段话

<script>

'use strict';

var restr = /$$([\s\S]*?)$$/g;

document.body.innerHTML = document.body.innerHTML.replace(restr,'{% math %}\begin{aligned}$1\end{aligned}{% endmath %}')

</script>

然后你就可以肆意的贴数学公式了,这个方法的好处是,你可以用一些比较优秀的markdown编辑器将文本写好(因为这些编辑器一般支持mathjex不支持KaTeX,但是hexo用的math插件支持后者),然后原封不动的交给hexo。 谢谢大家一直以来的关注~~

@WrRan 改好了 现在可以看见了

veya2ztn commented May 17, 2016

@tangbotony @iissnan @seisman @Vinnl @earthday 我想我已经完美解决这个问题了 如我所说,可以用js在markdown渲染前将所有的$$..$$替换成 {% math %}\begin{aligned}.............\end{aligned}{% endmath %}
方法如下
在你所写的.md文本的正文最后加入下面这段话

<script>

'use strict';

var restr = /$$([\s\S]*?)$$/g;

document.body.innerHTML = document.body.innerHTML.replace(restr,'{% math %}\begin{aligned}$1\end{aligned}{% endmath %}')

</script>

然后你就可以肆意的贴数学公式了,这个方法的好处是,你可以用一些比较优秀的markdown编辑器将文本写好(因为这些编辑器一般支持mathjex不支持KaTeX,但是hexo用的math插件支持后者),然后原封不动的交给hexo。 谢谢大家一直以来的关注~~

@WrRan 改好了 现在可以看见了

@WrRan

This comment has been minimized.

Show comment
Hide comment
@WrRan

WrRan Jun 21, 2016

@veya2ztn 要在.md文本的正文最后加的那段代码是什么?我没看到= =
我看到你写的代码了。并且在我自己markdown的正文最后部分粘贴你的代码,但是运行时抛出如下错误:

Unhandled rejection Template render error: (unknown path) [Line 22, Column 67]
  unknown block tag: math
    at Object.exports.prettifyError (g:\git\blogs\node_modules\hexo\node_modules\nunjucks\src\lib.js:34:15)
    at Obj.extend.render (g:\git\blogs\node_modules\hexo\node_modules\nunjucks\src\environment.js:468:27)
    at Obj.extend.renderString (g:\git\blogs\node_modules\hexo\node_modules\nunjucks\src\environment.js:326:21)
    at g:\git\blogs\node_modules\hexo\lib\extend\tag.js:66:9
    at Promise._execute (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\debuggability.js:272:9)
    at Promise._resolveFromExecutor (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:473:18)
    at new Promise (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:77:14)
    at Tag.render (g:\git\blogs\node_modules\hexo\lib\extend\tag.js:64:10)
    at Object.tagFilter [as onRenderEnd] (g:\git\blogs\node_modules\hexo\lib\hexo\post.js:253:16)
    at g:\git\blogs\node_modules\hexo\lib\hexo\render.js:63:19
    at tryCatcher (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:502:31)
    at Promise._settlePromise (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:559:18)
    at Promise._settlePromise0 (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:604:10)
    at Promise._settlePromises (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:683:18)
    at Async._drainQueue (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\async.js:138:16)
    at Async._drainQueues (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\async.js:17:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

其中,可能导致错误的markdown数学公式为$x_{n+1}$

WrRan commented Jun 21, 2016

@veya2ztn 要在.md文本的正文最后加的那段代码是什么?我没看到= =
我看到你写的代码了。并且在我自己markdown的正文最后部分粘贴你的代码,但是运行时抛出如下错误:

Unhandled rejection Template render error: (unknown path) [Line 22, Column 67]
  unknown block tag: math
    at Object.exports.prettifyError (g:\git\blogs\node_modules\hexo\node_modules\nunjucks\src\lib.js:34:15)
    at Obj.extend.render (g:\git\blogs\node_modules\hexo\node_modules\nunjucks\src\environment.js:468:27)
    at Obj.extend.renderString (g:\git\blogs\node_modules\hexo\node_modules\nunjucks\src\environment.js:326:21)
    at g:\git\blogs\node_modules\hexo\lib\extend\tag.js:66:9
    at Promise._execute (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\debuggability.js:272:9)
    at Promise._resolveFromExecutor (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:473:18)
    at new Promise (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:77:14)
    at Tag.render (g:\git\blogs\node_modules\hexo\lib\extend\tag.js:64:10)
    at Object.tagFilter [as onRenderEnd] (g:\git\blogs\node_modules\hexo\lib\hexo\post.js:253:16)
    at g:\git\blogs\node_modules\hexo\lib\hexo\render.js:63:19
    at tryCatcher (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:502:31)
    at Promise._settlePromise (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:559:18)
    at Promise._settlePromise0 (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:604:10)
    at Promise._settlePromises (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\promise.js:683:18)
    at Async._drainQueue (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\async.js:138:16)
    at Async._drainQueues (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (g:\git\blogs\node_modules\hexo\node_modules\bluebird\js\release\async.js:17:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

其中,可能导致错误的markdown数学公式为$x_{n+1}$

@littlebeandog

This comment has been minimized.

Show comment
Hide comment
@littlebeandog

littlebeandog Oct 12, 2016

@veya2ztn
按照你说的替换$$完美解决.
但是你提供的script并不会生效呀- -求解

littlebeandog commented Oct 12, 2016

@veya2ztn
按照你说的替换$$完美解决.
但是你提供的script并不会生效呀- -求解

@WrRan

This comment has been minimized.

Show comment
Hide comment
@WrRan

WrRan Oct 15, 2016

我找到一种解决方案,之所以显示不出数学公式,是因为Markdown渲染器与之冲突,使用如下命令可以解决:

npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save

该解决方案在如何处理Hexo和MathJax的兼容问题中被提出。
希望对你们有所帮助。
👍

WrRan commented Oct 15, 2016

我找到一种解决方案,之所以显示不出数学公式,是因为Markdown渲染器与之冲突,使用如下命令可以解决:

npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-kramed --save

该解决方案在如何处理Hexo和MathJax的兼容问题中被提出。
希望对你们有所帮助。
👍

@pfchai

This comment has been minimized.

Show comment
Hide comment
@pfchai

pfchai Oct 22, 2016

应该是下划线_解析的时候的问题,有一种解决办法是公式中出现下划线_的时候,都用\_代替

pfchai commented Oct 22, 2016

应该是下划线_解析的时候的问题,有一种解决办法是公式中出现下划线_的时候,都用\_代替

@hangsz

This comment has been minimized.

Show comment
Hide comment
@hangsz

hangsz Nov 21, 2016

按照这个链接做就可以了,很简单。
http://blog.csdn.net/emptyset110/article/details/50123231

hangsz commented Nov 21, 2016

按照这个链接做就可以了,很简单。
http://blog.csdn.net/emptyset110/article/details/50123231

@ivan-nginx

This comment has been minimized.

Show comment
Hide comment
@ivan-nginx

ivan-nginx Jul 20, 2017

Collaborator

@veya2ztn dont understand u, write in English if not solved. If solved, close it please.

Collaborator

ivan-nginx commented Jul 20, 2017

@veya2ztn dont understand u, write in English if not solved. If solved, close it please.

@CHENXCHEN

This comment has been minimized.

Show comment
Hide comment
@CHENXCHEN

CHENXCHEN Jul 26, 2017

hi 我写了个插件用来解决这个问题,基于markdonw-it的md解析器
在解析md的时候就直接将其直接渲染成katex的html格式,需要额外引入katex.css即可。。
支持katex的行内以及整行渲染
hexo-renderer-markdown-it-plus

CHENXCHEN commented Jul 26, 2017

hi 我写了个插件用来解决这个问题,基于markdonw-it的md解析器
在解析md的时候就直接将其直接渲染成katex的html格式,需要额外引入katex.css即可。。
支持katex的行内以及整行渲染
hexo-renderer-markdown-it-plus

@ivan-nginx

This comment has been minimized.

Show comment
Hide comment
@ivan-nginx

ivan-nginx Jul 26, 2017

Collaborator

@CHENXCHEN can u show any live demo with this plugin?

Collaborator

ivan-nginx commented Jul 26, 2017

@CHENXCHEN can u show any live demo with this plugin?

@CHENXCHEN

This comment has been minimized.

Show comment
Hide comment
@CHENXCHEN

CHENXCHEN commented Jul 27, 2017

@ivan-nginx hi, u can see this plugin demo in hexo-renderer-markdown-it-plus-plugin-demo

@ivan-nginx ivan-nginx closed this Sep 5, 2017

@wafer-li wafer-li referenced this issue Jan 13, 2018

Merged

Add katex support #32

6 of 15 tasks complete
@morningstarwang

This comment has been minimized.

Show comment
Hide comment
@morningstarwang

morningstarwang Aug 1, 2018

我出现template render error的原因是使用了\over表示分数。换成\frac就一切正常了。
这期间曾经尝试过@hangsz的方法。

morningstarwang commented Aug 1, 2018

我出现template render error的原因是使用了\over表示分数。换成\frac就一切正常了。
这期间曾经尝试过@hangsz的方法。

@ivan-nginx

This comment has been minimized.

Show comment
Hide comment
@ivan-nginx

ivan-nginx Aug 1, 2018

Collaborator

NexT is rebased into organization repo.
If you want new feature, fix, or support, create new in NexT v6.x repo (desirable in English).

There is instructions on English or Chinese how to update from v5.1.x to v 6.x

You also may read this for details.


Math docs in EN or CN.

Collaborator

ivan-nginx commented Aug 1, 2018

NexT is rebased into organization repo.
If you want new feature, fix, or support, create new in NexT v6.x repo (desirable in English).

There is instructions on English or Chinese how to update from v5.1.x to v 6.x

You also may read this for details.


Math docs in EN or CN.

@ivan-nginx ivan-nginx added the v6.X.X label Aug 1, 2018

Repository owner locked and limited conversation to collaborators Aug 1, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.