Make span around [math] block marker configurable
这个提交包含在:
当前提交
387be32103
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';
|
||||
}
|
||||
```
|
||||
|
|
|
@ -33,6 +33,9 @@ class SimpleMathJaxHooks {
|
|||
private static function renderTex($tex, $parser) {
|
||||
$parser->getOutput()->addModules( 'ext.SimpleMathJax' );
|
||||
$parser->getOutput()->addModules( 'ext.SimpleMathJax.mobile' ); // For MobileFrontend
|
||||
return ["<span style='opacity:.5'>[math]${tex}[/math]</span>", 'markerType'=>'nowiki'];
|
||||
$attributes = [ "style" => "opacity:.5" ];
|
||||
Hooks::run( "SimpleMathJaxAttributes", [ &$attributes, $tex ] );
|
||||
$element = Html::Element( "span", $attributes, "[math]{$tex}[/math]" );
|
||||
return [$element, 'markerType'=>'nowiki'];
|
||||
}
|
||||
}
|
||||
|
|
正在加载...
在新工单中引用