Extension:TrustedMath

TrustedMath is an extension that allows embedding LaTeX equations on wiki pages, similarly to the built-in math renderer, but without dependency on Ocaml and working almost out of the box on Windows.

Usage
The reason that MediaWiki normally renders math via an intermediate Ocaml script, is because TeX is not inherently safe. The intermediate texvc script removes all unsafe markup. The TrustedMathe extension does not contain these validation mechanisms. Instead it allows certain users to write unvalidated LaTeX which can be embedded into a page by anyone.

Please note that normally math is validated for a reason. The author does not know the exact security implications, but it could be very well possible that users who are allowed to render math may crash your wiki, steal your passwords and delete your database, so do not allow access to users you don't trust.

Safe mode
The safe mode is enabled by default. The extension creates the Math: namespace, which is restricted to users with the editmath user right. You need to grant that right to sysops or some other group that you trust. These users can then put equations in the Math namespace. Those equations can be embedded using the &lt;math name="page in math namespace" /> syntax.

Unsafe mode
The unsafe mode allows math embedded in regular &lt;math>&lt;/math> syntax and is almost compatible with the built-in math renderer. To enable it set $wgTrustedMathUnsafeMode to true in LocalSettings.php.

Installation

 * Install LaTeX. Windows users may want to install LaTeX using the MiKTeX package
 * Download TrustedMath and unpack it into your extensions folder
 * Add the following line to the bottom of your LocalSettings.php: require_once( "$IP/extensions/TrustedMath/TrustedMath.php" );
 * Tell MediaWiki where the latex and dvipng renderers are located.
 * For Linux those are usually /usr/bin/latex and /usr/bin/dvipng</tt>
 * For Windows those are something like C:\Program Files\MiKTeX 2.8\miktex\bin\latex.exe</tt> and C:\Program Files\MiKTeX 2.8\miktex\bin\dvipng.exe</tt>
 * Set them in LocalSettings: $wgTrustedMathLatexPath = 'C:\Program Files\MiKTeX 2.8\miktex\bin\latex.exe'; $wgTrustedMathDviPngPath = 'C:\Program Files\MiKTeX 2.8\miktex\bin\dvipng.exe';</tt>
 * If you are using the safe mode, you need to give a group the editmath</tt> right. To do so for sysops, add to your LocalSettings: $wgGroupPermissions['sysop']['editmath'] = true;</tt>

Now test your installation. Create a page with the Riemann zeta function at Math:Riemann zeta: \zeta(s) = \sum_{n=1}^\infty n^{-s} = \frac{1}{1^s} + \frac{1}{2^s} + \frac{1}{3^s} + \cdots \;\;\;\;\;\;\;\sigma = R(s) > 1. \!

Embed it on another page using &lt;math name="Riemann zeta" /></tt>. It should now show:

$$ \zeta(s) = \sum_{n=1}^\infty n^{-s} = \frac{1}{1^s} + \frac{1}{2^s} + \frac{1}{3^s} + \cdots \;\;\;\;\;\;\;\sigma = R(s) > 1. \! $$

IIS users
IIS and possibly other Windows users need to set the environment variable USERPROFILE to a path that the webserver can read/write to. Add to LocalSettings.php:
 * $wgTrustedMathEnvironment = array( 'USERPROFILE' => 'C:\writablepath' );</tt>

Math support
Not all math syntax supported by the math renderer of Wikipedia is supported, such as \mathfrak. If you know how to fix this please leave a message at the talk page.