Mathematica Asked on October 22, 2021
I do not see how to remove <annotation encoding='Mathematica'
from generated MathML. Afaict it is not needed for a one way conversion and it often doubles the size of generated MathML.
How to do this quickly?
Shouldn’t "Annotations"->{}
option handle this?
(mathml = ExportString[Column@List@f[x], "MathML", "Annotations" -> {}]) // AbsoluteTiming // Column
0.0025588
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<semantics>
....
<annotation encoding='Mathematica'>TagBox[...</annotation> (*THIS is a waste of space for me*)
</semantics>
</math>
I can mathml->XMLElement->DeleteCase->ExportString but then the procedure takes +500% of time for something that could’ve been just dropped before.
mathml //
ImportString[#, "XMLElement"] & //
DeleteCases[#, XMLElement["annotation", ___], [Infinity]] & //
ExportString[#, "XML"] & //
AbsoluteTiming // Column
0.0108532
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<semantics>
...
</semantics>
</math>
Trace
reveals that XML`MathML`BoxesToSymbolicMathML
is used under the hood and it has an "IncludeMarkupAnnotations"
option which seems to do the job:
ExportString[Column@List@f[x], "MathML", "IncludeMarkupAnnotations" -> False]
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mtable>
<mtr>
<mtd>
<mrow>
<mi>f</mi>
<mo>⁡</mo>
<mo>(</mo>
<mi>x</mi>
<mo>)</mo>
</mrow>
</mtd>
</mtr>
</mtable>
</math>
Answered by Kuba on October 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP