Export to presentation or content MathML

### 2.7.7 Export to presentation or content MathML

You can translate the result of an expression into various types of MathML with the export_mathml command.

- export_mathml takes one mandatory argument and one optional argument:
  - expr, an expression.
  - Optionally, format, which can be content or display, specifying the output format.
- export_mathml(expr ⟨,format ⟩) returns the result of evaluating expr written in MathML, with a single math block which will be a semantics block. Choices for the second argument are:
  - None: the semantics block will contain both presentation and content MathML.
  - content: the semantics block will contain only the content MathML.
  - display: the semantics block will contain only the presentation MathML.

#### Examples

xml_print(export_mathml(a+2*b))

<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'> <semantics> <mrow xref='id5'> <mi xref='id1'>a</mi> <mo>+</mo> <mrow xref='id4'> <mn xref='id2'>2</mn> <mo>&it;</mo> <mi xref='id3'>b</mi> </mrow> </mrow> <annotation-xml encoding='MathML-Content'> <apply id='id5'> <plus/> <ci id='id1'>a</ci> <apply id='id4'> <times/> <cn id='id2' type='integer'>2</cn> <ci id='id3'>b</ci> </apply> </apply> </annotation-xml> <annotation encoding='giac'>a+2*b</annotation> </semantics> </math>

xml_print(export_mathml(a+2*b,content))

<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'> <apply id='id5'> <plus/> <ci id='id1'>a</ci> <apply id='id4'> <times/> <cn id='id2' type='integer'>2</cn> <ci id='id3'>b</ci> </apply> </apply> </math>

xml_print(export_mathml(a+2*b,display))

<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'> <mrow> <mi>a</mi> <mo>+</mo> <mrow> <mn>2</mn> <mo>&it;</mo> <mi>b</mi> </mrow> </mrow> </math>

s:=export_mathml(1/(x^2+1),display):; xml_print(s)

<math mode='display' xmlns='http://www.w3.org/1998/Math/MathML'> <mfrac> <mn>1</mn> <mrow> <msup> <mi>x</mi> <mn>2</mn> </msup> <mo>+</mo> <mn>1</mn> </mrow> </mfrac> </math>