diff --git a/SimpleMathJaxHooks.php b/SimpleMathJaxHooks.php index 71cc9488..b715c6bc 100644 --- a/SimpleMathJaxHooks.php +++ b/SimpleMathJaxHooks.php @@ -1,4 +1,4 @@ -addJsConfigVars( 'wgSmjScale', $wgSmjScale ); $wgOut->addJsConfigVars( 'wgSmjEnableMenu', $wgSmjEnableMenu ); $wgOut->addJsConfigVars( 'wgSmjDisplayAlign', $wgSmjDisplayAlign ); + $wgOut->addModules( [ 'ext.SimpleMathJax' ] ); + $wgOut->addModules( [ 'ext.SimpleMathJax.mobile' ] ); // For MobileFrontend $parser->setHook( 'math', __CLASS__ . '::renderMath' ); if( $wgSmjUseChem ) $parser->setHook( 'chem', __CLASS__ . '::renderChem' ); } @@ -31,8 +33,6 @@ class SimpleMathJaxHooks { } private static function renderTex($tex, $parser) { - $parser->getOutput()->addModules( 'ext.SimpleMathJax' ); - $parser->getOutput()->addModules( 'ext.SimpleMathJax.mobile' ); // For MobileFrontend $attributes = [ "style" => "opacity:.5" ]; Hooks::run( "SimpleMathJaxAttributes", [ &$attributes, $tex ] ); $element = Html::Element( "span", $attributes, "[math]{$tex}[/math]" ); diff --git a/extension.json b/extension.json index b41ebfaa..5834ba88 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "SimpleMathJax", - "version": "0.8.2", + "version": "0.8.3", "author": [ "jmnote", "Qiuwen Baike Contributors" @@ -27,7 +27,8 @@ }, "ResourceModules": { "ext.SimpleMathJax": { - "scripts": ["resources/ext.SimpleMathJax.js"] + "scripts": ["resources/ext.SimpleMathJax.js"], + "targets": ["desktop", "mobile"] } }, "ResourceFileModulePaths": { diff --git a/resources/ext.SimpleMathJax.js b/resources/ext.SimpleMathJax.js index f2901a47..2261f8a6 100644 --- a/resources/ext.SimpleMathJax.js +++ b/resources/ext.SimpleMathJax.js @@ -1,4 +1,4 @@ -mw.hook( 'wikipage.categories' ).add( function ( $content ) { +mw.hook( 'wikipage.content' ).add( function ( $content ) { window.MathJax = { tex: { inlineMath: mw.config.get('wgSmjExtraInlineMath').concat([['[math]','[/math]']]),