-
-
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
mathml2chtml fails with a newline at the end. #2805
Comments
The reason this is happening is that MathJax parses the string you pass it as HTML, not XML (mainly to support embedded HTML in You can set what type of parsing will be used, however, in the options for the MathML input jax. MathJax = {
mml: {
parseAs: 'xml'
}
}; Unfortunately, there is a bug with the XML parsing that causes this to fail (it will be fixed in the next release). But you can work around it using MathJax = {
mml: {
parseAs: 'xml'
},
startup: {
ready() {
const {HTMLAdaptor} = MathJax._.adaptors.HTMLAdaptor;
HTMLAdaptor.prototype.body = function(doc) {return doc.body || doc};
MathJax.startup.defaultReady();
}
}
} for now. It would be reasonable for MathJax to trim the whitespace from the MathML before parsing it, however. |
Trimming whitespace was the solution I did to avoid the problem. It just took a while to figure out. I think MathJax trimming whitespace makes a lot of sense... but I don't know enough to know if there is any downside. Unfortunately the message "MathML must consist of a single element" wasn't helpful in figuring out the problem in that as far as I could tell, I was sending a single element. I thought that maybe there was bad tagging in the MathML I generated. |
Yes, the message could probably be better. But trimming the white space should be sufficient to resolve the main issue. |
Trim MathML string before parsing it. (mathjax/MathJax#2805)
Issue Summary
A newline at the end of some MathML in a call to mathml2chtml causes an error (actually, the call never returns)
This works
This fails:
Steps to Reproduce:
I tried to get a codepen example to run, and codepen complained about "MathJax" not being defined. Here's some HTML that shows the problem (the "AFTER..." is never shown):
The text was updated successfully, but these errors were encountered: