It's better when it's simple

User Tools

Site Tools


ASCIIMathML plugin

Compatible with DokuWiki

Lemming, Anteater, Rincewind

plugin Plugin for translating ASCII math notation to MathML on wiki pages

Last updated on

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to asciimath, jsmath, masciimath, math, math2, mathpublish

Tagged with formula, math, mathml


ASCIIMathML is a layer of JavaScript functions to convert ASCII math notation to Presentation MathML. The conversion is done while the (X)HTML page loads, and should work with Firefox/Mozilla/Netscape 7+ and Internet Explorer 6+ (Note: IE6+ requires Mathplayer to properly render the math notations).

ASCIIMathML plugin is based on version 1.4.8 Aug 30, 2007, © ASCIIMathML. This plugin does not support the Latest version of ASCIIMathML. For changes see ASCIIMath Changes.txt.



  1. Download the source archive (~14k)from ASCIIMathML - Plugin
  2. Unpack it in your Doku­Wiki plugins directory {dokuwiki}/lib/plugins; this will create the following folder:
  • {dokuwiki}/lib/plugins/asciimathml.

The folder shall contain the following files

  • ASCIIMathML148.js
  • script.js
  • syntax.php

That's it!

See here an image ofasciimathml in use

plugin codes


 * DokuWiki Plugin asciimathml (Syntax Component)
 * @license GPL 2
 * @author  Mohammad Rahmani <m [dot] rahmani [at] aut [dot] ac [dot] ir>
 *  Rev. 0.20: Some bugs fixed
 *  Date: Thursday, June 16, 2011
 *  Rev. 0.21: Some bugs fixed, support for the latest version of Dokuwiki (2011-05-25a)
 *  Date: Thursday, June 23, 2011
 *  -Note use <acm> tag for inline formatting
 *        use <acmath> tag for block formatting
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'syntax.php';
class syntax_plugin_asciimathml extends DokuWiki_Syntax_Plugin {
    public function getType(){ return 'formatting'; }
    public function getPType(){ return 'normal'; }
    public function getSort(){ return 450; }
     * Connect pattern to lexer
    public function connectTo($mode) {
    function postConnect() {
     * Handler to prepare matched data for the rendering process.
    public function handle($match, $state, $pos, &$handler){
        switch ($state) {
        case DOKU_LEXER_ENTER :
            return array($state, preg_match($match, "/^<acm>/"));
        case DOKU_LEXER_MATCHED :
            return array($state, $match);
        case DOKU_LEXER_EXIT :
            return array($state, preg_match($match, "/^<\/acm>/"));
        case DOKU_LEXER_SPECIAL :
        return array($state, '');
     * Handle the actual output creation.
    public function render($mode, &$renderer, $data) {
        if($mode != 'xhtml') return false;
        list($state, $match) = $data;
        switch ($state) {
        case DOKU_LEXER_ENTER :
            if ($match) {
                $renderer->doc .= '<span class="acmath"> `';
            } else {
                $renderer->doc .= '<div class="acmath"> `';
        case DOKU_LEXER_MATCHED :
            $renderer->doc .= $renderer->_xmlEntities($match);
        case DOKU_LEXER_EXIT :
            if ($match) {
                $renderer->doc .= ' `</span>';
            } else {
                $renderer->doc .= ' `</div>';


 This script installs the ASCIIMathML JavaScript
 to be used through "asciimath" plugin in DokuWiki
  Mohammad Rahmani
  Rev. 0: Trial
  Date: Friday, 25 Jul. 2008  10:14:40
  Rev. 0.20: Some bugs fixed
  Date: Thursday, June 16, 2011
  Rev. 0.21: Some bugs fixed
  Date: Thursday, June 23, 2011
   - all function in the previos script.js was deleted!
   - support for the latest version of Dokuwiki (2011-5-25a)
    * This plugin uses ASCIIMathML.js version 1.4.8 Aug 30, 2007, (c) Peter Jipsen
    * Latest version at
    * For changes see
    * If you use it on a webpage, please send the URL to
    * Note: This plugin ONLY SUPPORTS version 1.4.8 of ASCIIMathML.js
// full address to ASCIIMathML installation
document.write('<script type="text/javascript" src="' + DOKU_BASE + 'lib/plugins/asciimathml/ASCIIMathML148.js' + '"></script>');


  • For inline formula and when you don't want to start a div!
    <acm> ASCII Math Notation goes here </acm>
  • Formula rendered as a new paragraph
    <acmath> ASCII Math Notation goes here </acmath>

This is the syntax for the tag that inserts the MathML presentation on the wiki page. For detailed discussion take a look at ASCIIMathML Syntax.


There are many examples under ASCIIMathML samples. Here are some examples tested under DokuWiki, simply copy paste them into a wiki page with installed ASCIIMathML plugin.

==== Example 1 ====

  * A simple example

==== Example 2 ====

Matrices and column vectors are simple to type
 [[a ,  b ],[c,  d]]((n),(k))

==== Example 3 ====

Grouping brackets don't have to match
(a,b]={x in RR | a < x <= b}

==== Example 4 ====

piecewise defined function are based on matrix notation
x/x={(1,if x!=0),(text{undefined},if x=0):}

==== Example 5 ====

Complex subscripts are bracketed, displayed under lim

==== Example 6 ====

  * A multi-lines formula
<acm> int (x+1)(e^(x//2) - 1) dx = (x+1)(2e^(x//2) - x)- int (2e^(x//2)-x) dx</acm>

<acm> \ \ \ \ =(x+1)(2e^(x//2) - x) - (4e^(x//2) - x^2/2) + C</acm>

<acm> \ \ \ \ = 2xe^(x//2) -x^2 + 2e^(x//2) -x - 4e^(x//2) + x^2/2 + C</acm>

<acm> \ \ \ \ = 2e^(x//2)(x-1)-x-x^2/2 + C</acm>

==== Example 7 ====

  * Prescripts simulated by subsuperscripts
{::}_(\ 92)^238U

  * Symbols can be stacked
 stackrel"def"= or \stackrel{\Delta}{=}" "("or ":=)

  * Accents can be used on any expression 
 hat(ab) bar(xy) ulA vec v dotx ddot y

You can try ASCIIMathML online here at ASCIIMathML.js sandbox.


  • The ASCIIMathML was implemented as a pseudo plugin here. It seems the plugin simply adds the ASCIIMathML.js into DokuWiki. There is PHP port for ASCIIMathML, it seems a PHP version of ASCIIMathML is a better solution.
  • Interested developers are invited to correct/modify the code to obey the DokuWiki rules and for better performance.
  • To support the latest version of ASCIIMathML which has graphics capability like asciisvg.


  1. Nothing reported by now!


This is a very nice plugin, when you can have it running…

  • You can decide to patch the asciimathml/ASCIIMathML148.js file to support Opera and other recent browsers, like this:
function AMisMathMLavailable() {
  if (navigator.appName.slice(0,8)=="Netscape")
    if (navigator.appVersion.slice(0,1)>="5") return null;
    else return AMnoMathMLNote();
  else if (navigator.appName.slice(0,9)=="Microsoft")
    try {
        var ActiveX = new ActiveXObject("MathPlayer.Factory.1");
        return null;
    } catch (e) {
        return AMnoMathMLNote();
// Opera support for MathML
  else if (navigator.appName=="Opera")
    return null;
  else return AMnoMathMLNote();

Alexander Mihailov 2010-10-14

  • Thank you to — rainglasz 2011/01/23 19:28 for correction to script.js
plugin/asciimathml.txt · Last modified: 2022-07-29 23:27 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki