Merge pull request #34 from cubercsl/master

fix: addModules even when there is no <math>
这个提交包含在:
Jmnote 2022-07-09 20:25:11 +09:00 提交者 GitHub
当前提交 a1157866f0
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 1 个文件被更改,包括 3 次插入3 次删除

查看文件

@ -1,4 +1,4 @@
<?php
<?php
class SimpleMathJaxHooks {
public static function onParserFirstCallInit( Parser $parser ) {
@ -13,6 +13,8 @@ class SimpleMathJaxHooks {
$wgOut->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]" );