This package consists of a Movable Type plug-in that makes it possible to write equations in LaTeX format in weblog entries. Equations are converted to PNG files which are stored as part of the generated HTML, using the data: URL. (Internet Explorer users will therefore be unable to view the equations; both Safari and Mozilla-derived browsers can display the equations.)

Acknowledgements

This code is derived from Kjell Magne Fauske's code, available from <http://fauskes.net/nb/htmleqII/>. I reworked it to integrate with Movable Type's environment. Changes:

Requirements

Installation

  1. Once Python and ElementTree have been installed, put eqhtml.py somewhere. You could put it into /usr/local/bin or into your MT installation's plug-in directory; I use /www/scripts/.
  2. Edit mt-math.pl to use the correct path for eqhtml.py.
  3. Copy mt-math.pl into your MT installation's plug-in directory.

Usage

The plug-in adds a new text formatting type when you're editing a weblog entry. In addition to the usual 'None' and 'Convert Line Breaks' choices, you will now have a 'Math to HTML' choice that applies the equation-formatting filter. This means that you can't both convert link breaks and use math. In entries that use equations, you'll have to put <p> at the start of every paragraph.

Equations are indicated by <div> or <span> elements of class 'eq'. For example:

<div class="eq">
  y = \int_0^\infty \gamma^2 \cos(x) dx
</div>
<p> An inline equation <span class="eq">y^2=x^2+\alpha^2</span> here.</p>

Unfortunately, Movable Type doesn't support very good error handling. If you make an error in the LaTeX equation, the plug-in has no way to report the LaTeX errors. Instead it will leave the HTML alone, meaning that you'll see the LaTeX source in the published version of the entry.

See <http://www.amk.ca/diary/archives/004046.html> for a sample entry in my weblog that demonstrates some equations.

Fauske suggests using CSS to align the equations a bit better:

/* Center block equations */
div.eq {text-align:center;}

/* Align inline equations with parent's content area */
span.eq img {vertical-align:text-bottom;}

Download the code

mt-math.tgz [4K]

This code is made available under the MIT license.


[Contact me]