You should note that the MathML specification does not provide for the
usage you are suggesting (though I know how useful it would be).
Firefox's behavior is when <semantics> contains an <annotation-xml>
node as its first (only?) node, it will display that, but this
structure is not allowed by the MathML specification, which implies
that a standard (i.e., non-annotation) MathML node should be the
first child of a <semantics> element (see http://www.w3.org/TR/MathML3/chapter5.html#mixing.semantic.annotations
, particularly the first paragraph of 5.2.1.1).
Even with the improved annotation-xml support in the coming v1.1a,
however, MathJax will not handle the recursive processing of the
embedded MathML inside an XHTML annotation within a MathML element.
The contents of the annotation element are not further processed by
MathJax once they are identified.
Davide
The <annotation-xml> code in v1.1 is broken, but it is being corrected in v1.1a (currently in final testing).
You should note that the MathML specification does not provide for the usage you are suggesting
Anyway, I have a couple of questions:
1. Is it always a <span> element that is used, or are there other
elements that are the direct children of a MathML element like <mrow>?
2. It is always just plain text intermixed with <math> elements, or
are there other HTML elements used (like <b> or <input>, etc.)?
3. How much is it worth to you to get this working in MathJax (i.e.,
would you be willing to pay for me to produce some custom extensions
for MathJax that handle this for you)? We can have this discussion
privately, if you prefer.
Davide
It's very common among LaTeX authors to write something like \mbox{for
each $x>2}. In a XHTML+MathML document, that would result in something
like the above code.
<math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>f</mi> <mo stretchy="false">(</mo> <mi>x</mi> <mo stretchy="false">)</mo> <mo>></mo> <mn>0</mn> <mspace width="1em" /> <mtext>for each </mtext> <mrow> <mi>x</mi> <mo>></mo> <mn>2</mn> </mrow> </math>
<mn>0</mn>
<mspace width="1em" />
<mrow>
<span xmlns="http://www.w3.org/1999/xhtml" class="embedded-
html">
I had a similar thought in mind (which your answers to the questions
suggest would work). My first thought was to write a MathJax
preprocessor that would make the translation that you suggest, but
without the <math> tags, since they are not needed, and in fact
invalid (I think). XSL would be another way to handle that.
The alternative would be to implement a span node type in MathJax.
The former has the advantage that the MathML is then valid MathML, so
if you use the Show Source menu option, it will be something you can
copy and paste into other applications. The disadvantage is that it
requires an additional preprocessing step, but that should be
relatively fast.
The latter has the advantage that it would take the MathML you have
directly, and could be made to include other HTML tags inside the
<span>. The disadvantage is that it is more complicated to write, and
in particular, the nested MathML inside the span would take some care.
Either is possible. The first would be quicker to write, but a little
less flexible; the second takes more time, but allows for more complex
content.
Let me know if you want to work on either of these.
Davide
One thing that you might need to do is make the final space in the
first <mtext> into   (the entity reference for a non-breaking
space), and the same for the initial space in the second <mtext>. The
MathML specification states that leading and trailing spaces are
removed from token elements, so if you want to have spaces, you need
to make sure they are non-breaking spaces.
> This solves our problem.
Glad to hear you got it to work out!
> So far, the results of testing MathJax are very positive, so we'll
> probably use it in our e-learning platform.
Excellent. Let us know how it goes (and what your site is).
Best of luck with it.
Davide