-
Notifications
You must be signed in to change notification settings - Fork 232
External MathML files with object does not work with MathJax
From https://groups.google.com/d/msg/mathjax-users/5VOt3rJXHms/X1_ovYTCm5MJ
Is there a way that I can embed external MathML files in a HTML document? Usually I would do it with . Sadly this seems not to work with MathJax. Is there another way?
Well, I did some experiments and it looks like the files don't need to
contain anything other than a tag. I don't know how you are
In any case, assuming that your xml files contain a single tag,
<script type="text/x-mathjax-config">
MathJax.Extension.object2jax = {
version: "1.0",
PreProcess: function (element) {
if (typeof(element) === "string") {element =
document.getElementById(element)} if (!element) {element = document.body} var objects = element.getElementsByTagName("object"); for (var i = objects.length-1; i >= 0; i--) { var object = objects[i]; var math = ((object.contentDocument||{}).documentElement||{}); if (String(math.nodeName).toLowerCase() === "math") { math = document.importNode(math,true); object.parentNode.insertBefore(math,object); object.parentNode.removeChild(object); } } } };
MathJax .Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.object2jax], 5); // priority 5 is before mml2jax </script>
somewhere before the script that loads MathJax.js (or put it in your
local configuration file if you are using one). This will register a
preprocessor that will look for elements in tags and
Anyway, I think that will do what you need.
Davide