/MathJax

A MediaWiki extension that allows embedding mathematical formulas into wiki pages

Primary LanguagePHP

MathJax extension for MediaWiki

Version 2.1.

Alexander Mashin, based on work by Mithgol the Webmaster.

Overview

MathJax is a MediaWiki extension introducing a parser tag <math> that allows to embed mathematical formulae in TeX or MML into wiki pages.

Formulae are rendered by MathJax 3.0 or above, server-side (converted to MathML), client-side (re-rendered and menu added), or both.

Formulae can be wikified:

  • manually, e.g.: x' = \frac {x-vt} {\sqrt {1 - {v^2} / [[Speed of light|c]] ^ 2}},
  • or automatically, if $wgmjAddWikilinks = true, by defining MediaWiki messages linking wiki pages to TeX commands (starting with a backslash):
    • e.g., to add wikilinks to the Exponent page in your wiki to all \exp commands, add exp to the comma-separated list in the message MediaWiki:mathjax-pages and define a new message MediaWiki:mathjax-page-exp as Exponent.

New macros (e.g. \newmacro) are defined by adding newmacro to the comma-separated list stored in the message MediaWiki:mathjax-macros and creating the message MediaWiki:mathjax-macro-newmacro containing the definition of the macro.

Credits

The extension was initially written by Mithgol the Webmaster in 2010 and then rewritten completely several times by Alexander Mashin for Traditio wiki. In 2021, it is published at GitHub.

Requirements

The extension requires:

  • PHP 7.4 or higher,
  • MediaWiki 1.25 or higher,
  • MathJax 3.0 or higher.

Installation

To install the extension, copy or the entire MathJax folder or clone the repository into (path to mediawiki)/extensions folder. To enable the extension, add wfLoadExtension( 'MathJax' ); to LocalSettings.php.

If fourmulæ are to be rendered server-side, or MathJax is to be served from your server rather that from MathJax CDN, also run npm install (requires node.js) in MathJax folder. Make it accessible in the web server configuration. Otherwise, MathJax will be loaded from CDN.

Further information

For further information, see https://traditio.wiki/MathJax_for_MediaWiki.