1 The Web Platform

1.4 TeXZilla

Mathematical formulas are complex and hence writing mathematics is difficult. Some tools like WYSIWYG editors or handwriting recognition might help. One input method easy to implement is the conversion from a simple syntax like LaTeX into MathML. Even if there are tons of such converters, only a few of them are implemented in Javascript. Moreover the remaining ones try to tweak the output to workaround browser limitations, are not standalone Javascript module usable in add-ons and do not work with Unicode characters or right-to-left mathematics. Hence we decided to write yet another converters to focus on Mozilla’s needs.

We thus wrote TeXZilla [Wang3], a LaTeX-to-MathML converter generated with the help of Jison. It relies on a LALR(1) grammar and on the unicode.xml file of [W3C3], which contains an extensive list of Unicode characters used in science together with some semantic property and LaTeX commands to produce them. It accepts arbitrary Unicode input as well as right-to-left mathematics, something that is important for the world-wide aspect of the Mozilla community and more specifically Arabic mathematics.

The public API contains a toMathML function to convert a LaTeX string into a MathML DOM but also a toMathMLString function when the DOM is not available (e.g. in nodejs). There is also a convenient getTeXSource function to extract the LaTeX source from the MathML output and a toImage function to embed the MathML output inside a SVG image (see section 1.5).

TeXZilla can work in any CommonJS program [CommonJS], in Web pages, as a command line program or as a Web server. We have submitted a Firefox add-on that has been approved by the reviewers. We have also already integrated it into various other Mozilla tools: in CKEditor for the Mozilla Developer Network, in the Seamonkey/Thunderbird composers or in a Firefox OS web app (see section 2.4). Finally, a prototype <x-tex> custom element is also available (see section 1.5). We expect it will become an important library for future scientific applications.