Skip to content

A MediaWiki extension that allows embedding mathematical formulas into wiki pages

Notifications You must be signed in to change notification settings

alex-mashin/MathJax

Repository files navigation

MathJax extension for MediaWiki

Version 3.0.

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.33 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.

If, however, formulæ are to be rendered server-side in a MathJax container, do not run npm install, but copy the file src/engines/Dockerfile to an appropriate location, unless you already have the identical file includes/presets/cgi/Dockerfile from the extension External Data installed, build the image, set up the MathJax container and have it connected to your MediaWiki installation as described in the src/engines/docker-compose.yml file. Set $wgmjServiceUrl to the URL of the container, as connectable from MediaWiki. You might change the default values of $wgmjServiceExternalUrl and $wgnjServiceVersionUrl, too.

Further information

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

About

A MediaWiki extension that allows embedding mathematical formulas into wiki pages

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published