Blahtex and Blahtexml: Converting TeX equations into MathML

Blahtex(ml) pages

Files

Links

How to use blahtex(ml)?

The short answer is of course to read the manual, but here is an example to illustrate the use of blahtex.

Using the --mathml option

With the --mathml option, blahtex(ml) converts one TeX formula into MathML, from standard input to standard output. For instance, typing:

echo '\sqrt{x^2+\alpha}' | blahtex --mathml

produces:

<blahtex>
<mathml>
<markup>
<msqrt>
    <msup>
        <mi>x</mi>
        <mn>2</mn>
    </msup>
    <mo lspace="0.222em" rspace="0.222em">+</mo>
    <mi>α</mi>
</msqrt>
</markup>
</mathml>
</blahtex>

Using the --png option

With the --png option, blahtex(ml) converts one TeX formula into PNG. The name of the output file is automatically generated and is given as output. For instance, typing:

echo '\sqrt{x^2+\alpha}' | blahtex --png

produces:

<blahtex>
<png>
<md5>068bd5f892d1f87b0371fa570af10712</md5>
</png>
</blahtex>

and the file 068bd5f892d1f87b0371fa570af10712.png: .

Using the --xmlin option

This is specific to blahtexml. An input file looks like the following example.

<?xml version="1.0"?>
<equations xmlns:b="http://gva.noekeon.org/blahtexml">
  <equation b:inline="x+y"/>
  <equation b:block="\exp(-\gamma x)"/>
</equations>
</pre>

The equations are given as attributes (inline or block) in the http://gva.noekeon.org/blahtexml namespace. Whenever blahtexml meets such an equation, it expands it into the equivalent MathML code. The output corresponding to the previous example is given below.

<?xml version="1.0" encoding="UTF-8"?>
<equations xmlns:b="http://gva.noekeon.org/blahtexml">
  <equation>
    <math xmlns="http://www.w3.org/1998/Math/MathML">
      <mi>x</mi>
      <mo lspace="0.222em" rspace="0.222em">+</mo>
      <mi>y</mi>
    </math>
  </equation>
  <equation>
    <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
      <mstyle displaystyle="true">
        <mi>exp</mi>
        <mo lspace="0" rspace="0" stretchy="false">(</mo>
        <mo lspace="0" rspace="0">-</mo>
        <mi>γ</mi>
        <mspace width="0"></mspace>
        <mi>x</mi>
        <mo lspace="0" rspace="0" stretchy="false">)</mo>
      </mstyle>
    </math>
  </equation>
</equations>

Blahtexml has command-line options to fine-tune the XML output. One can specify the output document type declaration. Also, the representation of the MathML namespace can be adjusted. Blahtexml can also be used to generate XHTML+MathML. Please refer to the manual for more details.