我已经阅读了有关如何将内联数学模式添加到ghost的帖子:
http://ghost-rkingsbury.rhcloud.com/how-to-add-mathjax-to-a-ghost-blog/
我已添加到设置 - >代码注入:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true}
});
</script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
但收到错误:
jquery.fitvids.js:16 Uncaught TypeError: Cannot read property 'fn' of undefined
at jquery.fitvids.js:16
at jquery.fitvids.js:67
index.js:56 Uncaught ReferenceError: jQuery is not defined
at index.js:56
localhost/:3 Uncaught SyntaxError: Invalid or unexpected token
at eval (<anonymous>)
at EVAL (MathJax.js:19)
at Function.execute (MathJax.js:19)
at cb (MathJax.js:19)
at Object.Process (MathJax.js:19)
at Object.Push (MathJax.js:19)
at Object.ConfigBlocks (MathJax.js:19)
at Function.execute (MathJax.js:19)
at cb (MathJax.js:19)
at Object.Process (MathJax.js:19)
删除:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true}
});
</script>
允许渲染MathJax,但$ ... $不被识别为内联数学语句
将jQuery库添加到代码注入:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']],
processEscapes: true}
});
</script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
导致错误:
VM411:3 Uncaught SyntaxError: Invalid or unexpected token
at eval (<anonymous>)
at EVAL (MathJax.js?config=TeX-MML-AM_CHTML:19)
at Function.execute (MathJax.js?config=TeX-MML-AM_CHTML:19)
at cb (MathJax.js?config=TeX-MML-AM_CHTML:19)
at Object.Process (MathJax.js?config=TeX-MML-AM_CHTML:19)
at Object.Push (MathJax.js?config=TeX-MML-AM_CHTML:19)
at Object.ConfigBlocks (MathJax.js?config=TeX-MML-AM_CHTML:19)
at Function.execute (MathJax.js?config=TeX-MML-AM_CHTML:19)
at cb (MathJax.js?config=TeX-MML-AM_CHTML:19)
at Object.Process (MathJax.js?config=TeX-MML-AM_CHTML:19)
EVAL @ MathJax.js?config=TeX-MML-AM_CHTML:19
execute @ MathJax.js?config=TeX-MML-AM_CHTML:19
cb @ MathJax.js?config=TeX-MML-AM_CHTML:19
Process @ MathJax.js?config=TeX-MML-AM_CHTML:19
Push @ MathJax.js?config=TeX-MML-AM_CHTML:19
ConfigBlocks @ MathJax.js?config=TeX-MML-AM_CHTML:19
execute @ MathJax.js?config=TeX-MML-AM_CHTML:19
cb @ MathJax.js?config=TeX-MML-AM_CHTML:19
Process @ MathJax.js?config=TeX-MML-AM_CHTML:19
call @ MathJax.js?config=TeX-MML-AM_CHTML:19
WAITEXECUTE @ MathJax.js?config=TeX-MML-AM_CHTML:19
cb @ MathJax.js?config=TeX-MML-AM_CHTML:19
Execute @ MathJax.js?config=TeX-MML-AM_CHTML:19
loadComplete @ MathJax.js?config=TeX-MML-AM_CHTML:19
(anonymous) @ TeX-MML-AM_CHTML.js?V=2.7.0:68
我是否错过了尝试在Ghost中嵌入内联功能的步骤?
答案 0 :(得分:5)
我正在使用Ghost作为blog。
MathJax.Hub.Config
和脚本源需要在一个脚本块中才能使异步正常工作,否则MathJax.Hub.Config
将在MathJax.js
可用之前定义并生成错误。 Ghost演示页面:https://johnsiu.com/mathjax-test/
演示页面原始数据:
Inline : $ y = \int_0^1 {1\over x} dx $
Standalone: $$ y = \int_0^1 {1\over x} dx $$
<script type="text/javascript" async src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [["$", "$"], ["\\(", "\\)"]],
processEscapes: true
}
});
</script>
如果您在身边广泛使用mathjax
,请将脚本块移动到Ghost Setting->Code Injection
页眉或页脚。
使用FF和Chrome浏览器进行测试。