itex2MML

Current itex2MML Version: 1.6.1 (10/3/2021)
Current MT Plugin Version: 2.0 (1/2/2019)
Usage: itex Command Summary
Source code: (download | browse repository)

Introduction

This package contains the distribution for itex2MML. Binaries for MacOSX and Linux are provided in the itex-binaries directory. The source code is in the itex-src directory. It should compile on most platforms by simply typing

make
sudo make install

The resulting itex2MML binary is a stream filter. It takes text with embedded itex equations on STDIN, converts the itex equations to MathML, and outputs the resulting text on STDOUT.

Also included are Ruby bindings. The easiest way to obtain them, with a recent version of Rubygems is

gem install itextomml

Alternatively, if you have GNU make and SWIG 1.3, they can be built manually with

make ruby
make test_ruby
sudo make install_ruby

The Rubygem provides four public methods

itex.html_filter(a_string)

converts all itex equations in a_string to MathML, passing the rest of a_string unmodified. Returns the converted string.

itex.filter(a_string)

converts all itex equations in a_string to MathML. Returns just the MathML equation(s), as a string.

itex.inline_filter(a_string)

treats a_string as an inline equation (automatically supplies the surrounding $...$, so you don't have to) and converts it MathML. Returns the MathML inline equation, as a string.

itex.block_filter(a_string)

treats a_string as a block equation (automatically supplies the surrounding $$...$$, so you don't have to) and converts it MathML. Returns the MathML block equation, as a string.

Note that the commandline tool and the Ruby library return MathML named entities in the output. On the public web, it is safest to convert these either to utf-8 characters or to NCRs. For that, the itex_stringsupport.rb library included with the Rubygem adds the following methods to the String class: String#to_ncr, String to_utf8, String#to_ncr! and String#to_utf8!.

For Perl users, there are Perl modules, MathML::itex2MML and MathML::Entities (both available on CPAN), which provide exactly the same functionality as described for the Rubygem.

As of version 1.5, itex2MML includes the original itex source as an <annotation encoding="application/x-tex"> element, so that the source is available programmatically. On this blog, you can double-click on an equation to view the source in a popup window.

Finally, there's a MovableType (3.0 or greater) plugin which provides two Text Filtering options:

  1. itex to MathML
  2. itex to MathML with parbreaks

The plugin relies on the MathML::itex2MML Perl module (which you'll need to install) to do the actual conversion. The first filter is a straight itex2MML translation. The latter uses the "TeX" (and blogger's) convention that two linebreaks in succession signify a new paragraph. (The bloggers also like to convert single linebreaks to <br />, but that would mess with TeX formula entry, so we don't support it.)

A second plugin (also included) provides additionalText Filtering options.

  1. Textile with itex to MathML
  2. Markdown with itex to MathML

Details describing this plugin are available separately. It requires both the itex2MML plugin and the Textile and/or Markdown plugins.

See the itex Command Summary page and the Paul Gartside's page for more details on composing in itex and using the itex2MML program. The version of itex2MML included here is greatly-enhanced, with many bugfixes and support for a larger subset of LaTeX/AMSLaTeX syntax.

Below I've put some simple notes specific to the use of this plugin.

Usage Notes

  1. Tex equations are delimited by $...$ (inline) or \[...\] (display). Alternatively, $$...$$ can also be used to delimit display equations. So, just as in a TeX document, be sure you don't have any free-floating $'s in your text. If you want to enter something that renders as a $, use the unicode entity &#36;.
  2. The itex2MML stream filter does not distinguish between $$...$$ and \[...\]. Both result in display equations. However, the MovableType plugin and Maruku, the Ruby Markdown implementation, do distinguish between them. Both have automatic equation-numbering: \[...\] results in a numbered equation. You can add an optional label

    \[...\label{foo}...\]

    and then you can refer to the equation with either (eq:foo) or \eqref{foo}. These are automatically turned into hyperlinks.

  3. If you are using the "itex to MathML with parbreaks" filter, paragraph breaks are inserted automatically, whenever you insert a blank line in your text. If you are using the plain "itex to MathML" filter, you need to put in the paragraph (and any other) XHTML tags yourself.

  4. Mozilla only renders MathML when you serve the document as XML (ie using the MIME type application/xhtml+xml rather than text/html). You had better be producing 100% valid XHTML if you want to see anything when Mozilla is operating in that mode.
  5. The best way to serve up XML to Mozilla, while still catering to other browsers is to use mod_rewrite rules in the .htaccess file of your blog. See this blog entry for how to do that.

Plugin Installation Instructions

  1. Put the contents of the plugins directory into your MovableType plugins directory.
  2. Run
    cpan install MathML::itex2MML

As with Paul Gartside's original version, itex2MML is Open Source software, released under a triple license: GPL, MPL and LGPL.