-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 fails on entities #2650
Comments
MathJax doesn't load all the entity names initially for two reasons: first, there are a lot of them, and most pages won't be using the, and second, for in-browser use, the browser will usually translate the entities before MathJax runs, so there is usually no reason for it to need them. In the case of an unknown entity, however, you are right, MathJax will try to load one of its files and fail. This was set up for use in server-side node applications, and doesn't work in-browser. There are two possible solutions: First, there is an option that controls whether to try to load the extra entity names, and you can turn that off: MathJax = {
startup: {
ready() {
MathJax._.util.Entities.options.loadMissingEntities = false;
MathJax.startup.defaultReady();
}
}
}; (Note that you don't need the The second would be to load all the entity names, so MathJax won't try to load any individual files. For this, use
That will mean all the entity definitions are loaded, and MathJax won't need to load any other files. As it happens, I had been looking at this myself the day before your issue was posted, and was already planning to change this for in-browser use. It is good to have an issue tracker to remind me to make sure that happens. |
Thank you for you answer!
I have noticed this as well and I think that this should be in the documentation. Now it says in the docs on MathML that either a
Thanks a lot for you input and best regards! |
... and oh, I forgot in all my eagerness to talk about potential bugs, thanks for a TRULY GREAT framework :) |
Tanks for your kind words, and your additional information about React. I agree that you should not get the message and that that needs to be fixed. That is what I meant when I said I was going to change that in the next release. I gave you the other alternatives as a work-around until then. |
What bugs me a bit is that in the setting with React that I'm talking about ... if the MathML is given as a string to the You can see the behaviour here https://codesandbox.io/s/mathjax-react-entities-bug-egeef?file=/src/App.js Try changing the entity in In the same example we can see that React handles I will stop dwelling on this now :D |
I'm not able to get this to work as you say, but perhaps this is what's happening: MathJax only tries to load the file once, and if it fails, the next entity starting with that letter will be considered undefined. So that may be what is causing the behavior that you see.
MathJax contains a number of the entity definitions without having to download a file. I believe these are the ones from the MathML entities list if I remember correctly. Note that |
Sorry was a bit unclear.
|
OK, thanks for the updated instructions. I am able to reproduce it now. I think it has something to do either with React or with the way codesandbox.io works. It turns out that in some cases, the entity startup: {
ready() {
const Entities = window.MathJax._.util.Entities;
const translate = Entities.translate;
Entities.translate = (text) => {
console.log('translate: ', text);
return translate(text);
}
window.MathJax.startup.defaultReady();
}
} into the On the initial run (unedited App.js), I get
Note that the initial
followed by the error message about the file not being found. Changing back to
where the So this is not about MathJax handling Incidentally, I load the sandbox fresh and select mj.js for editing and paste in the configuration code above, the auto-run occurs, and I see the initial translate messages, but with
Then if I reload the right-hand frame using the reload icon, I get |
Note: the typeset button properly renders the |
Thanks for taking your time to answer! Your observations are in line with mine. However, I don't think we should blame the sandbox as I have been able to reproduce the exact same results locally without sandboxes. Nonetheless, I think it is as you say... the BROWSER itself knows how to interpret the entity so if it's up to the browser, the entity is correctly translated before MathJax processing. When we use the The reason to my interest is that I'm writing a library for MathJax use in React so this is very valuable to me. But I agree with you that the only problem with MathJax is that it tries to download non-existing files, other than that, MathJax is clean.. and we have already discussed that so I'm happy with this outcome. All the best to you my friend! |
Thanks for the kind words. It was an interesting problem to look into. Good luck with your project! |
…ilter for entities to load the full entity component when MathML input is used. (mathjax/MathJax#2650)
Make path resolving more flexible, and don't fail when loading entity files. (mathjax/MathJax#2650)
Issue Summary
When MathJax encounters a non-existing entity, it tries to download a file that does not exist and then fails. I don't expect MathJax to be able to handle non-existing entities, but the error is still odd (should produce
MathProcessing error
or something instead). Is this behaviour expected and desired?Steps to Reproduce:
Check code pen https://codepen.io/fast-reflexes/pen/LYbabaY and check the console (the actual browser console) for an error message when MathJax tries to download non-existing file
https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.1.2/es5/util/entities/f.js
when presented with non-existing entity&fpp;
.Any other information you want to share that is relevant to the issue
being reported. Especially, why do you consider this to be a bug? What
do you expect to happen instead?
Technical details:
The text was updated successfully, but these errors were encountered: