You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 24, 2020. It is now read-only.
on website, mathjax need refresh to display formulas, but when mathjax use forceSVG:true or create pdf, it report errors:
Error: TypeError: speech.processExpression is not a function
at GetSpeech (/Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/gitbook-plugin-mathjax/node_modules/mathjax-node/lib/mj-single.js:540:29)
at Function.execute (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:243:26)
at cb (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:225:59)
at Object.Process (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:495:38)
at Object.call (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:508:37)
at Function.WAITEXECUTE (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:348:50)
at cb (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:225:59)
at Object.Process (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:495:38)
at Object.call (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:508:37)
at Function.WAITEXECUTE (file:///Users/linrongbin/devenv/project/Way-to-Algorithm/node_modules/mathjax/unpacked/MathJax.js:348:50)
Hi @walkccc
Where does the scripts plugin add the JS in the page? If fix.js is loaded before mathjax, it won't work.
I vaguely remember during my troubleshooting process adding both sequentially to the .md file with no luck, so there may also be a race condition occurring.
If your gitbook is small, try manually adding the script to the bottom of each .md file? I ended up placing the script with some other js in a separate plugin that made the site header, but this may not be appropriate in your case.
Hi @Chrisjake
My gitbook is very big(about 500 .md files)
I've tried a small case to append the <script> .... </script> in the end of the .md file. It still not work and require refresh to show the math equation.
@SamyPesse The root cause of this problem is that the CDN used for Mathjax changed. PR is here: #39
@walkccc@Chrisjake etc, the above PR isn't much use to anyone else because head revision of this plugin only work for gitbook>4. If you wanted to use this you could see the PR above for changes and/or use my update_cdn branch/fork in your gitbooks:
CDN of mathjax should be changed from cdn.mathjax.org/mathjax to cdnjs.cloudflare.com.
As for gitbook, we can modify one line in {root_of_your_gitbook}/node_modules/gitbook-plugin-mathjax/index.js from 'https://cdn.mathjax.org/mathjax/' + version + '/MathJax.js?config=TeX-AMS-MML_HTMLorMML', to 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML'. There are also other files using the old cdn url, you can find it by grep command and change it to up-to-date url.
BTW, if you visit https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML and take a look into this code, you'll find why we need to refresh the page to reload those math elements.
Activity
kalaider commentedon May 22, 2017
+1
linrongbin16 commentedon Oct 6, 2017
same problem:
on website, mathjax need refresh to display formulas, but when mathjax use
forceSVG:true
or create pdf, it report errors:cjdbarlow commentedon Dec 5, 2017
Hacky workaround courtesy of @quangounet, but adding a JS loop fixes the problem:
hamishwillee commentedon Jan 3, 2018
@Chrisjake Awesome - works fine if added into the page - thanks! Any plans to push a PR for this?
walkccc commentedon Jan 26, 2018
My "book.json" looks like this
{
"plugins": [
"mathjax",
"splitter",
"toggle-chapters",
"scripts"
],
"pluginsConfig": {
"scripts": {
"files": [
"./fix.js"
]
}
}
}
And my "fix.js" looks like this:
<script> gitbook.events.bind("page.change", function() { MathJax.Hub.Queue(["Typeset", MathJax.Hub]); } </script>After adding these codes, it still can't work properly.
Anything wrong with the codes?
cjdbarlow commentedon Jan 27, 2018
Hi @walkccc
Where does the scripts plugin add the JS in the page? If fix.js is loaded before mathjax, it won't work.
I vaguely remember during my troubleshooting process adding both sequentially to the .md file with no luck, so there may also be a race condition occurring.
If your gitbook is small, try manually adding the script to the bottom of each .md file? I ended up placing the script with some other js in a separate plugin that made the site header, but this may not be appropriate in your case.
walkccc commentedon Jan 27, 2018
Hi @Chrisjake
My gitbook is very big(about 500 .md files)
I've tried a small case to append the <script> .... </script> in the end of the .md file. It still not work and require refresh to show the math equation.
hamishwillee commentedon Jan 28, 2018
@walkccc Just FYI, you are not alone - the solution did not work for me either (I thought it did, but sadly not). I have not tried to debug this yet.
hamishwillee commentedon Mar 20, 2018
@SamyPesse The root cause of this problem is that the CDN used for Mathjax changed. PR is here: #39
@walkccc @Chrisjake etc, the above PR isn't much use to anyone else because head revision of this plugin only work for gitbook>4. If you wanted to use this you could see the PR above for changes and/or use my update_cdn branch/fork in your gitbooks:
(although I don't guarantee it won't move).
NOTE: You can't also have the script running that is recommended above, as this will render the maths twice!
southball commentedon Aug 6, 2018
The problem is still occurring, but it seems I was able to 'fix' it by modifying
book/plugin.js
to this:I'm not sure if this will affect the functioning of the plugin, could someone take a look at this and see if this fixes the problem? @SamyPesse
It seems that currently the browser warns that
MathJax is not defined
asMathJax
is accessed before the script is loaded.Edit: I modified it to use
load
and notDOMContentLoaded
.hamishwillee commentedon Aug 7, 2018
@JamieChoi I think updating the mathjax CDN as above is probably a better fix #34 (comment)
Joeeyy commentedon Jul 21, 2019
CDN of mathjax should be changed from
cdn.mathjax.org/mathjax
tocdnjs.cloudflare.com
.As for gitbook, we can modify one line in
{root_of_your_gitbook}/node_modules/gitbook-plugin-mathjax/index.js
from'https://cdn.mathjax.org/mathjax/' + version + '/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
to'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
. There are also other files using the old cdn url, you can find it bygrep
command and change it to up-to-date url.BTW, if you visit
https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
and take a look into this code, you'll find why we need to refresh the page to reload those math elements.