Previous Up Next

3.7.6  Export to presentation or content MathML: export_mathml

The command export_mathml accepts one or two arguments: an expression and optionally the symbol content or display. If content is specified, it converts the expression to content MathML, while for display it converts it to presentation MathML. If the second argument is omitted, the return value contains both presentation and content MathML within a semantics block. The return value in each case is a string containing a single math block.

For example, input:

xml_print(export_mathml(a+2*b))

Output:

<math 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>

Input:

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

Output:

<math 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>

Input:

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

Output:

<math 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>

Previous Up Next