0
votes

Does anyone know where to find a tool that converts MathML to a plain text math expression?

For example, I want to input

<math xmlns='http://www.w3.org/1998/Math/MathML'>
 <mfrac>
  <mrow>
   <mi>cos</mi>
   <mo>&#8289;</mo>
   <mo>(</mo>
   <msup>
    <mi>x</mi>
    <mn>2</mn>
   </msup>
   <mo>)</mo>
  </mrow>
  <mrow>
   <mi>sqrt</mi>
   <mo>&#8289;</mo>
   <mo>(</mo>
   <mrow>
    <mi>y</mi>
    <mo>+</mo>
    <mn>2</mn>
   </mrow>
   <mo>)</mo>
  </mrow>
 </mfrac>
</math>

And get as output the string

cos(x^2) / sqrt(y + 2)

I've been unable to find anything that works like this by searching Google.

Any help is appreciated.

2
Google gave me pmathmlascii as an answer. This is said to be able to transfer your MathML to readable ASCII artuser8408080
@user8408080 I want to convert it to a text expression, not ASCII art. Like this, but reversed.Enter Display Name Here
"Text expression" like in "Ready to copy paste into wolframalpha" (for example)?user8408080
Exactly what I wantEnter Display Name Here
I don't think, that there is a general tool for this, as every program interpretes these formulas differently (for example think about how this should handle integrals). These conversions are most likely all one can get. Maybe your problem is solvable if you tell exactly what the goal isuser8408080

2 Answers

1
votes

It seems that "plain text" is the catch here – there is no clear definition of what format that is when it comes to mathematical expressions. I managed to find AsciiMath which fits the description pretty well.

There appears to be a number of tools for converting MathML to AsciiMath, for example mathml-to-asciimath.

1
votes

If you have Word or Pages you can download mathpix from the internet and snip the math ml or mathjax equation using it and copy it to Word then there you can finally copy the text version of the equation.