MathJax-node
MathJax-node copied to clipboard
mml3 extension not compatible [was: syntax for mml3 extension in config]
I'm trying to figure out how to enable mml3.js. It's unclear to me from the documentation what to put in my config object. Can someone help me out?
mathJaxApi.config({
MathJax: {
SVG: {
font: "TeX"
},
styles: {
'.mfrac': {
'font-size': '92.1%'
}
},
extensions: "MathML/mml3"
}
});
Untested, just off the top of my head.
mathJaxApi.config({
MathJax: {
SVG: {
font: "TeX"
},
styles: {
'.mfrac': {
'font-size': '92.1%'
}
},
extensions: "MathML/mml3.js"
}
});
or following the documentation.
mathJaxApi.config({
MathJax: {
SVG: {
font: "TeX"
},
styles: {
'.mfrac': {
'font-size': '92.1%'
}
},
MathML: {extensions: ["mml3.js"] }
}
});
Neither of those works, unfortunately. By which I mean, when I put in some mathml, I don't get a response at all from my server. No error, or anything. I assume that means the config isn't in the right format.
I tried this:
mathJaxApi.config({
MathJax: {
SVG: {
font: "TeX"
},
styles: {
'.mfrac': {
'font-size': '92.1%'
}
},
MathML: {extensions: "mml3.js"}
}
});
And I gave it some mathml, a vertical addition problem, and got the error message:
"unknown node type: mstack"
Which is the same message I get when I don't try to load mml3 at all, so I can't tell whether the extension was actually loaded, or if it did load, and it doesn't like my mathml. :(
example mathML:
<math xmlns="http://www.w3.org/2010/Math/MathML"><semantics><mstyle scriptsizemultiplier="0.715"><mstack charalign="center" stackalign="right"><mn>1</mn><msrow><mo>+</mo><mn>3</mn></msrow><msline/><msrow/></mstack></mstyle><annotation encoding="text/plain">one plus three</annotation></semantics></math>
There are two things going on here. First, it looks like the mml3 extension expects you to use the m:
namespace; @pkra, do you know a reason for that, or is it just that that is how David's code came to us? So you would have to use <m:math>
and so on, and would also need to specify xmlns: "m"
in your data being sent to the MathJax Typeset()
call.
The other, and more serious, issue is that jsdom doesn't seem to implement the XSLTProcessor
object on which the mml3 extension is based. Without that, the mml3 extension can't run. So even with the needed namespace, mml3 won't work in mathjax-node. I see no immediate work-around for this.
@pkra, do you know a reason for that, or is it just that that is how David's code came to us?
Just the way David's code is set up.
The other, and more serious, issue is that jsdom doesn't seem to implement the XSLTProcessor object on which the mml3 extension is based.
Oh, right, I forgot about that part. @corinnaSchultz sorry for writing replies on the go.
I see no immediate work-around for this.
Agreed.
@corinnaSchultz your best bet is probably to take the underlying xslt and run it over your MathML before passing it to mathjax-node.
I'll hunt down an xslt transformer then, that seems like the best option.
Thanks, @corinnaSchultz. I'm marking this upstream as we want to implement a pure JS version of this extension in core MathJax anyway (which would fix this).