MediaWiki Extension SimpleMathJax
转到文件
WaitSpring b97e3e670f update sub-module 2022-12-13 23:53:27 +08:00
resources update sub-module 2022-12-13 23:53:27 +08:00
.editorconfig Add editorconfig file for MW defaults 2020-11-10 21:54:56 -05:00
.gitmodules update mirror url 2022-04-29 16:58:40 +08:00
LICENSE Create LICENSE 2020-10-23 20:07:03 +09:00
README.md Update hook name and add documentation 2020-11-15 19:08:16 -05:00
SimpleMathJax.php wfLoadExtension 2017-06-12 02:11:02 +09:00
SimpleMathJaxHooks.php fix: addModules with array argument 2022-07-04 21:32:38 +08:00
extension.json Merge branch 'master' of https://git.qiuwen.wiki/mirror/SimpleMathJax into dev 2022-09-08 15:27:48 +08: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
  • LocalSetting.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';
	}