Update hook name and add documentation
这个提交包含在:
父节点
d38cd5057d
当前提交
ef5de943c6
13
README.md
13
README.md
|
@ -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'];
|
||||
}
|
||||
|
|
正在加载...
在新工单中引用