MediaWiki Extension SimpleMathJax
Go to file
guyru 7c9de84d21
Update version in extension.json (#42)
0.8.3->0.8.4
2023-12-12 18:04:22 +09:00
resources MobileFrontend fix 2022-07-06 07:44:41 -05:00
.editorconfig Add editorconfig file for MW defaults 2020-11-10 21:54:56 -05:00
.gitmodules . 2020-10-19 03:45:43 +09:00
LICENSE Create LICENSE 2020-10-23 20:07:03 +09:00
README.md Update README.md 2022-10-02 22:32:53 +09:00
SimpleMathJax.php wfLoadExtension 2017-06-12 02:11:02 +09:00
SimpleMathJaxHooks.php Remove space before opening tag in SimpleMathJaxHooks.php 2023-11-04 09:45:34 +02:00
extension.json Update version in extension.json (#42) 2023-12-12 18:04:22 +09:00

README.md

The SimpleMathJax extension enables MathJax, a Javascript library, for typesetting TeX formula in MediaWiki inside math environments.

https://www.mediawiki.org/wiki/Extension:SimpleMathJax

Installation

  • git clone in extensions directory
  • Using CDN is recommended. Because it's much faster than using local resources in most cases. ("the benefits of using a CDN")
$ git clone https://github.com/jmnote/SimpleMathJax.git
  • (Optional) If you want to use not CDN but local mathjax scripts, you can use git clone recursive.
$ git clone --recursive https://github.com/jmnote/SimpleMathJax.git
  • LocalSettings.php
wfLoadExtension( 'SimpleMathJax' );

Optional Settings

Setting name Description default value custom value example
$wgSmjUseCdn use CDN or local scripts true false
$wgSmjUseChem enable chem tag true false
$wgSmjEnableMenu MathJax.options.enableMenu true false
$wgSmjDisplayMath MathJax.tex.displayMath [] '$$','$$'],['\[','\]'
$wgSmjExtraInlineMath MathJax.tex.inlineMath [] '\(', '\)'
$wgSmjScale MathJax.chtml.scale 1 1.5
$wgSmjDisplayAlign MathJax.chtml.displayAlign center left
$wgSmjWrapDisplaystyle wrap with displaystyle true false

If you want to change font size, set $wgSmjScale.

wfLoadExtension( 'SimpleMathJax' );
$wgSmjScale = 1.5;

If you want to use local module, set $wgSmjUseCdn.

wfLoadExtension( 'SimpleMathJax' );
$wgSmjUseCdn = false;

If you want to enable some extra inlineMath symbol pairs, set $wgSmjExtraInlineMath.

wfLoadExtension( 'SimpleMathJax' );
$wgSmjExtraInlineMath = [["$","$"],["\\(","\\)"]];

If you want to disable MathJax context menu, set $wgSmjEnableMenu.

wfLoadExtension( 'SimpleMathJax' );
$wgSmjEnableMenu = false;

Hooks

The hook SimpleMathJaxAttributes is available to add attributes to the span around the math. This hook provides you with the opportunity to ensure that your own code does not interfere with MathJax's rendering of math.

For instance, if Lingo's JS functions are called before MathJax is invoked, then it is possible that Lingo will change the text so that MathJax could no longer render the math.

Lingo understands that it should not touch anything inside an element with the class noglossary so the following code can be used to keep Lingo from ruining math:

$wfHook['SimpleMathJaxAttributes']
	= function ( array &attributes, string $tex ) {
		$attributes['class'] = 'noglossary';
	}