Welcome to the web page dedicated to blahtex and blahtexml.
What are blahtex and blahtexml?
Blahtex is a program written in C++, which converts an equation given in a syntax close to TeX into MathML. It is designed by David Harvey and is aimed at supporting equations in MediaWiki.
Blahtexml is a simple extension of blahtex. In addition to the functionality of blahtex, blahtexml has XML processing in mind and is able to process a whole XML document into another XML document. Instead of converting only one formula at a time, blahtexml can convert all the formulas of the given XML file into MathML.
Due to their big overlap, blahtex and blahtexml are maintained together.
How to build blahtex(ml)?
Blahtexml requires one to have the XML parser library Xerces-C 2.x installed, to which blahtexml dynamically links.
If you do not have Xerces-C installed, you can still build and use the original blahtex, since blahtexml is a source-level superset of blahtex. The few differences in blahtex due to blahtexml are enclosed in conditional compilation directives.
To build blahtex (resp. blahtexml), you need to download the blahtexml sources, untar them in a directory and compile them by typing make blahtex-linux (resp. make blahtexml-linux) under Linux. It was successfully compiled using GCC 4.3.1 and Xerces-C 2.8 on Linux. For more details on other platforms, please refer to the manual.
How to use blahtex(ml)?
The short answer is of course to read the manual, but here is a short 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">
<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>
</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.
What is new in blahtexml 0.6?
Besides some bug fixing, the only change since the last version is the possibility to render "display math" formulas in PNG, thanks to a patch by Ari Stern.
What is new in blahtexml 0.5?
The main difference with version 0.4.4 is that both blahtex and blahtexml now accept Unicode mathematical symbols and Greek letters as input in math mode. These symbols are equivalent to their command counterparts. For instance, the following two lines are equivalent and will give the same output:
<eq b:inline="\Phi \leq \Omega \approx \Gamma"/><eq b:inline="Φ≤Ω≈Γ"/>
The first line uses the traditional TeX commands, while the second line uses the Unicode symbols directly. The full list of accepted symbols can be found in the manual.
Feedback
Feedback is greatly appreciated. For bug reporting and feedback in general, please contact me at gilles -dot- van -dot- assche -at- noekeon -dot- org.