logo4 Evolution is progress—                          
progress is creativity.        
vline

Test Math Formula HTML

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> &int; </mo>
    <mn> 0 </mn>
    <mn> 1 </mn>
   </msubsup>
   <mrow>
    <msqrt><mi> x </mi></msqrt>
    <mo> &InvisibleTimes; </mo>
    <mrow>
     <mo> &DifferentialD; </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.

0 1 x x

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

17+29i C

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

( 010 001 100 )

Examples from http://www.w3.org/Math/XSL/csmall2.xml


These two entries offer some useful suggestions.

  1. http://stackoverflow.com/questions/3219098/generating-equation-png-files-based-on-mathematical-input
  2. 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

  1. by calling a view with the urlencoded TEX formula.
  2. by storing a temporary image that has to be destroyed after its use.

some formula

The implementation is explained here.

some plot


Tags: Software

 
   

(c) Mato Nagel, Weißwasser 2004-2013, Disclaimer