mediawiki-extensions-Simple.../README.md

71 行
3.1 KiB
Markdown

2015-10-22 10:05:11 +08:00
The SimpleMathJax extension enables MathJax, a Javascript library, for typesetting TeX formula in MediaWiki inside math environments.
https://www.mediawiki.org/wiki/Extension:SimpleMathJax
2017-05-18 02:17:03 +08:00
2017-06-12 01:20:26 +08:00
# Installation
2017-12-28 23:12:43 +08:00
* git clone in extensions directory
2018-04-30 08:37:18 +08:00
* Using CDN is recommended. Because it's much faster than using local resources in most cases. ("the benefits of using a CDN")
2017-06-12 01:20:26 +08:00
```Bash
2017-12-28 23:12:43 +08:00
$ git clone https://github.com/jmnote/SimpleMathJax.git
2017-05-18 02:17:03 +08:00
```
2017-12-28 21:42:27 +08:00
2017-12-28 23:17:08 +08:00
* (Optional) If you want to use not CDN but local mathjax scripts, you can use git clone recursive.
2017-12-28 21:42:27 +08:00
```Bash
$ git clone --recursive https://github.com/jmnote/SimpleMathJax.git
```
2017-06-12 01:20:26 +08:00
* LocalSetting.php
2017-05-18 02:17:03 +08:00
```PHP
2017-06-12 01:20:26 +08:00
wfLoadExtension( 'SimpleMathJax' );
2017-05-18 02:17:03 +08:00
```
2017-06-12 21:04:54 +08:00
# Optional Settings
2020-10-23 18:29:01 +08:00
| Setting name | Description | default value | custom value example |
2020-10-23 18:27:41 +08:00
| ------------------------ | -------------------------------- | ------------- | --------------------------- |
| `$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 |
2017-05-18 02:17:03 +08:00
2020-10-21 15:31:57 +08:00
If you want to change font size, set `$wgSmjScale`.
2017-05-18 02:17:03 +08:00
```PHP
2017-06-12 01:20:26 +08:00
wfLoadExtension( 'SimpleMathJax' );
2020-10-19 03:49:36 +08:00
$wgSmjScale = 1.5;
2017-05-18 02:17:03 +08:00
```
2017-06-12 02:58:14 +08:00
2020-10-19 03:49:36 +08:00
If you want to use local module, set `$wgSmjUseCdn`.
2017-06-12 02:58:14 +08:00
```PHP
wfLoadExtension( 'SimpleMathJax' );
2020-10-19 03:49:36 +08:00
$wgSmjUseCdn = false;
2017-06-12 02:58:14 +08:00
```
2020-10-19 03:49:36 +08:00
If you want to enable some extra inlineMath symbol pairs, set `$wgSmjExtraInlineMath`.
2017-06-12 21:04:54 +08:00
```PHP
wfLoadExtension( 'SimpleMathJax' );
2020-10-19 03:49:36 +08:00
$wgSmjExtraInlineMath = [["$","$"],["\\(","\\)"]];
2017-06-12 21:04:54 +08:00
```
2019-10-20 21:14:30 +08:00
2020-10-21 15:31:30 +08:00
If you want to disable MathJax context menu, set `$wgSmjEnableMenu`.
2019-10-20 21:14:30 +08:00
```PHP
wfLoadExtension( 'SimpleMathJax' );
2020-10-19 03:49:36 +08:00
$wgSmjEnableMenu = false;
2019-10-20 21:14:30 +08:00
```
2020-11-16 08:05:04 +08:00
# 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`](https://www.mediawiki.org/wiki/Extension:Lingo#Excluding_text_from_markup) so the following code can be used to keep Lingo from ruining math:
```PHP
$wfHook['SimpleMathJaxAttributes']
= function ( array &attributes, string $tex ) {
$attributes['class'] = 'noglossary';
}
```