Update hook name and add documentation

这个提交包含在:
Mark A. Hershberger 2020-11-15 19:05:04 -05:00
父节点 d38cd5057d
当前提交 ef5de943c6
找不到此签名对应的密钥
GPG 密钥 ID: C5E6B11787B8FA01
共有 2 个文件被更改,包括 14 次插入1 次删除

查看文件

@ -55,3 +55,16 @@ 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`](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';
}
```

查看文件

@ -34,7 +34,7 @@ class SimpleMathJaxHooks {
$parser->getOutput()->addModules( 'ext.SimpleMathJax' );
$parser->getOutput()->addModules( 'ext.SimpleMathJax.mobile' ); // For MobileFrontend
$attributes = [ "style" => "opacity:.5" ];
Hooks::run( "SimpleMathJaxAttr", [ &$attributes, $tex ] );
Hooks::run( "SimpleMathJaxAttributes", [ &$attributes, $tex ] );
$element = Html::Element( "span", $attributes, "[math]{$tex}[/math]" );
return [$element, 'markerType'=>'nowiki'];
}