-
-
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
CHTML causes errors with some latex environments, when rendered outside main DOM tree #1185
Comments
Hm... I thought MathJax could not render nodes that are unattached because certain DOM operations fail. @dpvc? |
Correct, and that is what is happening here. The problem is that MathJax needs to use element ID's to look up elements on the page in some circumstances, and if the elements are not actually in the page (as in this case), they won't be found, and MathJax will fail. In this case, the In addition to needing to look up the elements by ID, MathJax needs an active DOM to measure the font em-size and ex-height, and may need to measure some other items like characters that are not in its fonts, or "foreign" elements like HTML or SVG embedded in So for all these reasons, you need to be in the actual page. Processing math in an HTML fragment that is not part of the page is not a supported use case. What is actually happening for your HTML-CSS output is the following (I suspect -- I didn't actually confirm this): when MathJax tries to determine the em-size and ex-height, if it gets 0 (usually meaning that the measurements can't be taken because the math is in a container with The current Fast HTML output is still very preliminary, and does not move the math if it can't determine the ex-height. So if you use that output (either as a preview, or as the actual final version), you will run into the lookup-by-ID problems described above. But for HTML-CSS and SVG, a side effect of our handling |
Thanks for the explanation. Everything worked fine till 2.5 so I assumed I'll try placing it in my own hidden area before typesetting. |
Issue filed on mathjax-docs => closed as "expected behavior" |
I'm dynamically typesetting nodes created outside the document and only insert them afterwards [*].
I started getting some [Math Processing Error]s with 2.5.
It happens only if Fast Preview is enabled or if Fast HTML renderer is chosen.
Observed in Chrome and Firefox (on linux), didn't try other browsers.
Here is a minimal case: http://codepen.io/cben/pen/BNNXvQ
The errors I saw were with latex environments but I don't think all environments are broken; e.g. example 2 only errors with equation numbering enabled.
With the help of #1184 I got the following stack traces:
1:
2, 3:
I briefly dived into debugging those but gave up. That code is too dense with unfamiliar context for me.
[*] I believe I have no choice as I'm inserting them as into CodeMirror [https://cben.github.io/CodeMirror-MathJax/demo.html]; even if I inserted nodes first and typeset later, CodeMirror doesn't materialize the whole DOM but only the currently scrolled portion. The codepen I linked doesn't involve CodeMirror.
The text was updated successfully, but these errors were encountered: