wgSmjWrapDisplaystyle

这个提交包含在:
jmnote 2020-10-23 19:25:34 +09:00
父节点 abe7f68964
当前提交 85cf5ced71
共有 2 个文件被更改,包括 17 次插入12 次删除

查看文件

@ -1,33 +1,33 @@
<?php
class SimpleMathJax {
class SimpleMathJaxHooks {
public static function onParserFirstCallInit( &$parser ) {
public static function onParserFirstCallInit( Parser $parser ) {
global $wgOut, $wgSmjUseCdn, $wgSmjUseChem, $wgSmjEnableMenu,
$wgSmjDisplayMath, $wgSmjExtraInlineMath,
$wgSmjScale, $wgSmjDisplayAlign;
$wgOut->addJsConfigVars( 'wgSmjUseCdn', $wgSmjUseCdn );
$wgOut->addJsConfigVars( 'wgSmjUseChem', $wgSmjUseChem );
$wgOut->addJsConfigVars( 'wgSmjEnableMenu', $wgSmjEnableMenu );
$wgOut->addJsConfigVars( 'wgSmjDisplayMath', $wgSmjDisplayMath );
$wgOut->addJsConfigVars( 'wgSmjExtraInlineMath', $wgSmjExtraInlineMath );
$wgOut->addJsConfigVars( 'wgSmjScale', $wgSmjScale );
$wgOut->addJsConfigVars( 'wgSmjEnableMenu', $wgSmjEnableMenu );
$wgOut->addJsConfigVars( 'wgSmjDisplayAlign', $wgSmjDisplayAlign );
$parser->setHook( 'math', __CLASS__ . '::renderMath' );
if( $wgSmjUseChem ) $parser->setHook( 'chem', __CLASS__ . '::renderChem' );
}
if( $wgSmjUseChem ) $parser->setHook( 'chem', __CLASS__ . '::renderChem' ); }
public static function renderMath($tex, array $args, Parser $parser, PPFrame $frame ) {
global $wgSmjWrapDisplaystyle;
$tex = str_replace('\>', '\;', $tex);
$tex = str_replace('<', '\lt ', $tex);
$tex = str_replace('>', '\gt ', $tex);
if( $wgSmjWrapDisplaystyle ) $tex = "\displaystyle{ $tex }";
return self::renderTex($tex, $parser);
}
public static function renderChem($tex, array $args, Parser $parser, PPFrame $frame ) {
return self::renderTex('\ce{'.$tex.'}', $parser);
return self::renderTex("\ce{ $tex }", $parser);
}
private static function renderTex($tex, $parser) {
@ -37,3 +37,7 @@ class SimpleMathJax {
}
}

查看文件

@ -1,25 +1,26 @@
{
"name": "SimpleMathJax",
"version": "0.8.0",
"version": "0.8.1",
"author": "jmnote",
"url": "https://www.mediawiki.org/wiki/Extension:SimpleMathJax",
"description": "render TeX between <code><nowiki><math></nowiki></code> and <code><nowiki></math></nowiki></code>",
"license-name": "GPL-2.0+",
"type": "parserhook",
"AutoloadClasses": {
"SimpleMathJax": "SimpleMathJax_body.php"
"SimpleMathJaxHooks": "SimpleMathJaxHooks.php"
},
"config": {
"SmjUseCdn": {"value":true, "description":"true to load mathjax from CDN"},
"SmjUseChem": {"value":true, "description":"true to enabled chem tag"},
"SmjEnableMenu": {"value":true, "description":"MathJax.options.enableMenu"},
"SmjDisplayMath": {"value":[], "description":"MathJax.tex.displayMath"},
"SmjExtraInlineMath": {"value":[], "description":"MathJax.tex.inlineMath"},
"SmjScale": {"value":1, "description":"MathJax.chtml.scale"},
"SmjDisplayAlign": {"value":"left", "description":"MathJax.chtml.displayAlign"}
"SmjEnableMenu": {"value":true, "description":"MathJax.options.enableMenu"},
"SmjDisplayAlign": {"value":"left", "description":"MathJax.chtml.displayAlign"},
"SmjWrapDisplaystyle": {"value":true, "description":"true to wrap with displaystyle"}
},
"Hooks": {
"ParserFirstCallInit": "SimpleMathJax::onParserFirstCallInit"
"ParserFirstCallInit": "SimpleMathJaxHooks::onParserFirstCallInit"
},
"ResourceModules": {
"ext.SimpleMathJax": {