how to get the original Tex code

562 views
Skip to first unread message

rch...@gmail.com

unread,
May 15, 2011, 7:12:48 AM5/15/11
to mathja...@googlegroups.com
hi, how can i get the original Tex code of a MathJax element after it's typeset.

Davide P. Cervone

unread,
May 15, 2011, 8:24:08 AM5/15/11
to mathja...@googlegroups.com
> hi, how can i get the original Tex code of a MathJax element after
> it's typeset.

In order to do this, you will need access to the MathJax ElementJax
object for the mathematics. You can get that via

MathJax.Hub.getJaxByInputType("math/tex")

which returns an array of all the element jax that come from TeX
input. You step through the array, or obtain the element by index.
If there is a specific element that contains the math, you can pass
that as a second parameter to getJaxByInputType(). For example, if
there is a single math expression containing in a DIV with
id="MathOutput", then

var jax = MathJax.Hub.getJaxByInputType("math/tex","MathOutput")[0];

will get you the ElementJax for that expression.

Then use

jax.SourceElement().text

to get the original text.

Davide


rchod

unread,
May 15, 2011, 12:06:03 PM5/15/11
to mathja...@googlegroups.com
hi, thanks Davide it works good.
I have another question, when i set the mathDiv (a dive containing Tex code) on contenteditable="true" and when i modify the the render of the Tex code, the jax.SourceElement().text doesn't change too ! can you explain me why.

Davide P. Cervone

unread,
May 24, 2011, 8:20:13 PM5/24/11
to mathja...@googlegroups.com
I'm not sure I understand you setup.   You are editing the OUTPUT of MathJax?  Certainly that will not be reflected in the input, as the transformation is one way.  It would be difficult to convert that back into TeX notation.

If that's not the situation, please explain further what you are trying to do.

Davide
Reply all
Reply to author
Forward
0 new messages