I am trying to use the example
// a simple TeX-input example
var mjAPI = require("mathjax-node/lib/mj-single.js");
mjAPI.config({
MathJax: {
// traditional MathJax configuration
}
});
mjAPI.start();
var yourMath = 'E = mc^2';
mjAPI.typeset({
math: yourMath,
format: "TeX", // "inline-TeX", "MathML"
mml:true, // svg:true,
}, function (data) {
if (!data.errors) {console.log(data.mml)}
});
from this page.
From what I see the method typeset
passes the output I need to a function input in its second argument.
I don't want to print the output data.mml
. I need to assign it to an external variable for further processing.
Question: How can I assign data.mml
to a variable that is outside the scope of the anonymous function passed to typeset
?
The anonymous function is not able to modify variables from the global scope (outside typeset
) because that is not the immediate scope from the the anonymous function is called.