javascriptmathmlmathtype

How to convert numbers or characters to MathML format?


Sample examples,

yes -> <math xmlns="http://www.w3.org/1998/Math/MathML"><mi>y</mi><mi>e</mi><mi>s</mi></math>
99  -> <math xmlns="http://www.w3.org/1998/Math/MathML"><mn>99</mn></math>

For those given inputs, I would like to get the corresponding mathml expressions. I'm doing this because mathtype.setMathML(99) won't work, it should be mathtype.setMathML(<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>99</mn></math>) I'm using mathtype_web.


Solution

  • <mtext> comes into the rescue. we can use it to render either numbers or characters.

    mathtype.setMathML(<math xmlns="http://www.w3.org/1998/Math/MathML"><mtext>{NUMBER or CHARACTERS}</mtext></math>)