The first test were disappointing. It seems no mathematical formulas work with Creole.
Neither the mediawiki HTML format
{{math|{{radical|1 − ''e''²}}}}
Nor the TEX format
<math> f(x) = x^2\,\!</math>
Nor MathML
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<msubsup>
<mo> ∫ </mo>
<mn> 0 </mn>
<mn> 1 </mn>
</msubsup>
<mrow>
<msqrt><mi> x </mi></msqrt>
<mo> ⁢ </mo>
<mrow>
<mo> ⅆ </mo>
<mi> x </mi>
</mrow>
</mrow>
</mrow>
</math>
Überschrift mit einer in MathML gesetzten Formel
Although I created a macro that is capable to display this, but it is not convenient to read.
An other example.
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mrow>
<mn>17</mn>
<mo>+</mo>
<mn>29</mn>
<mo/>
<mi>i</mi>
</mrow>
<mo></mo>
<mi mathvariant="double-struck">C</mi>
</mrow>
</math>
Is rendered as
And finally
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow><mo>(</mo><mtable>
<mtr><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd><mtd><mn>0</mn></mtd></mtr>
<mtr><mtd><mn>0</mn></mtd><mtd><mn>0</mn></mtd><mtd><mn>1</mn></mtd></mtr>
<mtr><mtd><mn>1</mn></mtd><mtd><mn>0</mn></mtd><mtd><mn>0</mn></mtd></mtr>
</mtable><mo>)</mo></mrow>
</math>
yields
Examples from http://www.w3.org/Math/XSL/csmall2.xml
These two entries offer some useful suggestions.
- http://stackoverflow.com/questions/3219098/generating-equation-png-files-based-on-mathematical-input
- http://stackoverflow.com/questions/617668/looking-for-a-self-contained-equation-rendering-library
As I decided to implement matplotlib anyway, I opted for MathtextBackend. Unfortunately this is poorly documented. Although a tutorial and an extended example is available, no examples cover how it is used with web applications.
I learned from this webpage how to provide matplotlib graphics from a web server. An idea how to integrate matplotlib into django I found here.
This leaves us with two options how to implement matplotlib graphics
- by calling a view with the urlencoded TEX formula.
- by storing a temporary image that has to be destroyed after its use.
The implementation is explained here.