What you'll get
This method uses ASCIIMathML by Peter Jipsen.
After implementing this patch you'll be able to use simple ASCII syntax to write formulae that will be rendered as MathML. Math should be written between double dollar signs like this $$sqrt(a^2+b^2)$$. The ASCII syntax could be described as "the way you would write it in some simple language like matlab" or for the more advanced users - LaTeX where you can (but don't have to) omit the backslashes.
This page can be used for near-WYSIWYW (what you see is what you want) editing of formulae in your wiki page (note that there you have to use single dollar sign or back quote).
Here is a bitmap of example rendering by firefox
Get ASCIIMathML.js
Download ASCIIMathML.js and save it in moins htdocs directory (the directory in which all the moin's static stuff is kept, like images and css files).
Changes Required for Version 2.0.1 of ASCIIMathML.js
If using version 2.0.1 of ASCIIMathML.js, edit the file with a text editor and around line 46 change the line
to
Around line 54, change the line
to
Changes Required for Version 1.4.7 of ASCIIMathML.js
If using version 1.4.7 of ASCIIMathML.js, edit the file with a text editor and at around the line 38 replace the lines
with
These changes will prevent the script from recognizing every back quote or dollar sign as math delimiter.
Change wikiconfig.py
Add the following to you wikiconfig.py (be sure to indent the first line properly for the html_head variable to be part of the config class)
This line will cause Moin to add the <script> line to html header of every page.
If your wiki is one of the wikis in a wiki farm which is configured by farmconfig.py, change the variable name DefaultConfig to FarmConfig in the above example and add the changed text to your wiki configuration file.
If you are using Moin version less than 1.6, change the variable name url_prefix_static to url_prefix.
Add ASCIIMathML rule to wiki parser
With this rule wiki will recognize that anything between double dollar signs is math and will not attempt to interpret it as wiki markup (which could lead to some very curious results).
Moin version 1.8.2 (tested on 1.8.2-2ubuntu2.1)
Apply this patch to parser/text_moin_wiki.py under the Ubuntu MoinMoin directory /usr/share/python-support/python-moinmoin/MoinMoin (I moved the original file to text_moin_wiki.py.old):
--- text_moin_wiki.py.old 2009-01-17 22:55:07.000000000 -0500 +++ text_moin_wiki.py 2009-09-21 21:55:54.000000000 -0400 @@ -363,6 +363,7 @@ (?:\|\|)+(?:<(?!<)[^>]*?>)?(?!\|?\s$) # a table )|(?P<rule> -{4,} # hor. rule, min. 4 - +)|(?P<asciimath>\$\$.*?\$\$ )|(?P<entity> &( ([a-zA-Z]+) # symbolic entity, like ü @@ -1327,6 +1328,11 @@ return self.formatter.macro(self.macro, macro_name, macro_args, markup=groups.get('macro')) _macro_name_repl = _macro_repl _macro_args_repl = _macro_repl + + def _asciimath_repl(self, word, groups): + """Recognize math between double dollar signs for AsciiMathML + to prevent the parser from messing with it""" + return word def scan(self, line, inhibit_p=False): """ Scans one line
Moin version 1.5.6 to Moin version 1.5.8
Edit the file parser/wiki.py under MoinMoin directory. Around line 91: before the line (before, not instead)
(?P<tt_bt>`.*?`)""" % {
add the line:
(?P<asciimath>\$\$.*?\$\$)
Around line 859: before the line
def scan(self, scan_re, line):
add
Moin Version 1.6
Edit the file parser/text_moin_wiki.py under the MoinMoin directory. Around line 271 before the line (before, not instead)
)|(?P<interwiki>
add the lines:
)|(?P<asciimath> \$\$ # asciimath on (?P<asciimath_text>.*?) # capture the text \$\$ # off
Around line 556 before the line
def _rule_repl(self, word, groups):
add
IMPORTANT: If you were testing it on some page and it didn't work, don't forget to delete the cache for the page when trying again.
How to use it
Follow the instructions here MathMlSupport/HelpOnMathematicalFormulas on how to make your browser display MathML properly and how to use the new syntax.