I suspect that you are not actually looking at the results of
MathJax's Typeset() call (which you don't want to edit), but actually
the original HTML that you created (the correct thing to edit), and
that it is not MathJax that is changing the entities but the browser
itself. MathJax doesn't leave the original MathML in the page, it
removes it, so unless you are asking for MathJax's original version, I
don't see that you could be looking at something that MathJax has
altered.
If you could be more specific about the details of what you are
looking at and how it is obtained, that might help us analyze the
situation.
Davide
You should not really be calling Typeset directly, but should be using
the MathJax.Hub command queue (see
http://www.mathjax.org/docs/2.0/queues.html#the-mathjax-processing-queue
for details), and whatever code depends on the results of the
typesetting should also be queued. Note that Typset() may return
before the math is fully rendered, so you must use the queue in order
to guarantee that MathJax is finished when you use its results.
> and this is our editor's content (I'm reporting the math source only,
> omitting mathjax output):
>
> <math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:mml="http://
> www.w3.org/1998/Math/MathML"> <mrow><mn>ⅇ</mn><mo> + </mo><mi>x</
> mi><mo></mo><mi>y</mi></mrow> </math>
>
> html entities are now (after the typeset) no more expressed in
> numerical form.
Again, I'm a little confused by what you mean "the math source only".
Are you talking about the contents of the <script type="math/mml"> in
which MathJax has stored the original MathML? In that case, your
results make sense, because (as I pointed out in my original
response), the mml2jax preprocessor uses innerHTML to get the contents
of the original math element, and the entities have already been
replaced by the browser at that point. So the contents of the
<script> will be the actual unicode characters rather than entity
references.
If you want the scripts to contain your original entities, then you
should insert your math via
parentWindow.tinyMCE.activeEditor.setContent(currentData + '<script
type="math/mml">' + data + "</script><p> </p>", {format : 'numeric'});
rather than using a paragraph. That will put the code directly into
the script as you originally had it, and so it will not be subject to
the interaction with the browser that the mml2jax preprocessor does.
You will then no need to run the preprocessor (but that would require
not using a combined configuration file; not sure whether you are or
not; in any case, it won't hurt to run the preprocessor, it just isn't
necessary).
> We tried both to call MathJax's Remove() and SourceElement() methods
> to get back to the "original" version before storing the math in the
> DB. The only way I can go back to the "original" encoding is to right
> click on the rendered formula and choose "show math as mathml code".
> In this way html entities as rendered in numerical form and that is
> exactly what we would need. Unfortunately, I can't find a method able
> to do this conversion in the API...
The output for the show source menu item is generated directly from
the MathJax internal representation. That is obtained from calling a
jax's toMathML() method, but you have to make sure the toMathML.js
extension is loaded first, and you have to use queues for this, since
it is asynchronous, as I recall. It is better to use the <script>
approach above, provided the setContent() allows it. There are some
issues in IE with including scripts when setting innerHTML. I'm not
sure how tinyMCE handles that, so it might not work as hoped.
Anyway, those are my ideas on your situation.
Davide
Note that MathJax will handle the CDATA block within the script on its
own, but I guess you will want to remove it in the end when you put
the contents back into the page anyway.
> The other limitation is that tinyMCE will change your script
> type="math/mml" in
> "mce-math/mml" in the resulting html.
> ...
> Anyway, is there a way to tell mathjax to typeset if the script tag
> has the type attribute "mce-math/mml"?
I'm wondering if you can use the postprocessor to change the className
of the script when you remove the CDATA block? That should allow
MathJax to process it.
If not, then something like
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("End Jax",function () {
var TEX = MathJax.InputJax.TeX;
if (TEX) {TEX.Register("mce-math/mml")}
});
</script>
should bind mce-math/mml to the TeX input jax (in addition to math/mml).
Davide