Note: You are currently viewing documentation for Moodle 3.0. Up-to-date documentation for the latest stable version of Moodle may be available here: ASCIIMathML.


From MoodleDocs

NOTE: With the use of Atto as an editor, MathJax has been included as a standard tool for writing Maths expressions.


Initially developed by Peter Jipsen ( see his remarks on the history of ASCIIMathML here ), ASCIIMathML has become one of the most widely and easily used tools for the expression and display of Mathematics on the web.


Display Usage


AsciiMathML has been massaged into quite a few formats, and is presently available in a version 2.0.2 distribution from Sourceforge which can be quickly installed for Moodle as a javascripted based filter.

However, in exploring various features of AsciiMathML it was discovered that once installed (per the default instructions) the filter did not turn off (There is a Tracker item on this [need to add reference]. It is argued that this behavior may be due to artifacts in the usage of require_js ) and that there were issues with the filter not interacting appropriately with the Moodle quiz and message modules. It is possible that the filter may be made to behave more like a filter if the javascript files are moved and the php files edited to reflect their location.

For the interim it was determined that asciimathml.js works very well if simply referenced in meta.php, and for those interested in using ASCIIMathML, it is suggested that a reference to it be placed in the appropriate theme and that a "common" location for the distribution files be identified (see below}

Additionally, a php version of ASCIIMathML has been developed by Steve Chan. Depending on usage, using the php version may or may not require the concurrent usage of an additional javascript file (arguably, if the web application displays XHTML, which Moodle does, the additional javascript file is not necessary.)

Stemming from an initial joint project with Peter Jipsen, David Lippman has also maintained a version of ASCIIMathML.js that provides fallback to a TeX interpreter such as mimetex. This can be important because ASCIIMathML requires that a) the browser used supports MathML (A W3C standard that Safari, for example does not support) and b) that adequate Math fonts are available to the browser (see note below about obtaining and installing fonts).

As part of extending the fallback option to make ASCIIMathML usage more transparent for usage on Moodle, a Moodle version will be available.

Display via MathJax

Thanks to David Lippman you can now parse ASCIIMathML for display using MathJax. The configuration information can be found at . This implementation does not include ASCIISVG.

Display via SEE

The Super Equation Editor (See Advanced Math Tools) provides a variety of tools to manage display of ASCIIMathML

Installation and Display via meta.php

WARNING!!! With the devellopment of separate docs for ech Moodle versin it is likely that much of this section WON'T work with Moodle 2, though the same concept can be implemented in Moodle 2.

Because of all the discussion regarding asciimathml and possible conflicts and fallback options please consider installing as follows pending the adoption of Moodle 2.0 and such integrations with tinyMCE as may be provided at that time.

From the sourceforge link above obtain the asciimath files. Place the asciimath folder in /lib so that you now have /lib/asciimath (the folder location has moved a bit over time, but I am recommending this change from placing the folder at /lib/editor/common/asciimath so as to be more consistent with other usage - Marc Grober 18:54, 1 July 2009 (UTC)) DO NOT place it with other filters in /lib/filter as it appears to continue to work whether it is turned on or not. If you are interested in fallback, you may copy this file to the asciimath folder and, backing up your original asciimathml.js file, replace it with this one, changing the references inside it to you local mimetex or mathtran server.

Now edit your meta.php to point to the new location. You will have a meta.php in your theme's directory and it will look something like the code below.... Note the inclusion of the two script stanzas. Just make sure the second points to the correct directory. <script type="text/javascript">

_editor_skin = "xp-blue"; // If you want use a skin, add the name (of the folder) here
_editor_lang = "en"; // And the language we need to use in the editor.
var mathcolor = "black"; // You may change the color the formulae are displayed (default: red)
var mathfontfamily = "Arial"; //and the font (default: serif, which is good I think)

<script type="text/javascript" src="<?php echo $CFG->httpswwwroot ?>/lib/asciimath/ASCIIMathML.js"></script> Now don't forget to install the STIX fonts.



Peter Jipsen created a google groups site here "for discussing issues and proposing additions to the JavaScript program ASCIIMathML.js that enables users to easily display mathematics and graphs (using MathML and SVG) on web pages or in blogs and wikis. Suggestions are welcome (see for more). "


Failure to display some tex

ASCIIMathML was intended to provide a quick and easy alternative to use and display of the text syntax employed by (la)tex. WHile it does this well, when it comes to the incremental features of either parsing and displaying tex text expressions, or if using fallback, converting asciimathml text expression to tex, there are occasions upon which the results of problematic. Most often, this can be resolved through using an alternative text expression that parses to the same results, and there is discussion in the Math Tools forum on such usage. Additionally, there is continuing research and effort in trying to provide a quick, easy, and seamless way to write and display math online.

Font usage generally

While Firefox does do MathML, the results are problematic without appropriate fonts. Initially the MIT fonts were recommended while Mozilla now recommends the STIX beta fonts. There has been some continuing discussion on whether Firefox should bundle such fonts, but at present you will have to download and install fonts separately. This is very easy to do and there are "how to"s to assist you.

Specific font issues

Discussion in the Assciimathml google group continues to yield "fixes" for specific font issues as possible, though some issues may reside in the browser. We hope that by the time Moodle 2 is released with tinyMCE an asciimathml version with falabck that addresses most known font issues will be available here


David Lippman developed a fallback script (a version is offered above) that invokes mimetex or mathtran if for some reason the script determines that the current browser can't display MathML. Versions have been passed about that provide session cookies so that warnings are provided once, that do away with any warnings, etc. At some point a full set of versins with explanations may be available, or perhaps a script with specific internal configuration instructions. In the meantime, if you have any questions post them to the Math Tools forum and we will try to answer them as quickly as possible

See Also