Extension:TrustedMath
TrustedMath Release status: beta |
|||
---|---|---|---|
Implementation | Tag | ||
Description | Embed LaTeX equations on wiki pages | ||
Author(s) | Bryan Tong Minh (Bryantalk) | ||
Latest version | 0.9.0 | ||
MediaWiki | 1.17 , 1.19, 1.28 and possibly lower versions as well | ||
License | MIT License | ||
Download | |||
|
|||
|
|||
|
|||
Translate the TrustedMath extension if it is available at translatewiki.net | |||
Check usage and version matrix. |
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[edit]
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[edit]
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 <math name="page in math namespace" />
syntax.
Unsafe mode[edit]
The unsafe mode allows math embedded in regular <math></math>
syntax and is almost compatible with the built-in math renderer. To enable it set $wgTrustedMathUnsafeMode
to true in LocalSettings.php.
Installation[edit]
- 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
anddvipng
renderers are located.- For Linux those are usually
/usr/bin/latex
and/usr/bin/dvipng
- For Windows those are something like
C:\Program Files\MiKTeX 2.8\miktex\bin\latex.exe
andC:\Program Files\MiKTeX 2.8\miktex\bin\dvipng.exe
- 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';
- For Linux those are usually
- If you are using the safe mode, you need to give a group the
editmath
right. To do so for sysops, add to your LocalSettings:$wgGroupPermissions['sysop']['editmath'] = true;
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 <math name="Riemann zeta" />
. It should now show:
IIS users[edit]
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' );
Math support[edit]
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.