.
这个提交包含在:
父节点
4936711917
当前提交
0327326557
|
@ -1,3 +0,0 @@
|
|||
[submodule "MathJax"]
|
||||
path = modules/MathJax
|
||||
url = https://github.com/mathjax/MathJax.git
|
|
@ -1,23 +1,24 @@
|
|||
<?php
|
||||
class SimpleMathJax {
|
||||
private static $moduleLoaded = false;
|
||||
|
||||
public static function onRegistration() {
|
||||
Hooks::register( 'ParserFirstCallInit', __CLASS__ . '::setup' );
|
||||
}
|
||||
|
||||
public static function setup( Parser $parser ) {
|
||||
global $wgOut, $wgSmjUseCDN, $wgSmjSize, $wgSmjUseChem, $wgSmjShowMathMenu, $wgSmjInlineMath;
|
||||
|
||||
$smjModule = $wgSmjUseCDN ? 'ext.SmjCDN' : 'ext.SmjLocal';
|
||||
$wgOut->addModules( $smjModule );
|
||||
global $wgOut, $wgSmjUseCdn, $wgSmjScale, $wgSmjUseChem, $wgSmjShowMathMenu, $wgSmjExtraInlineMath, $wgSmjDisplayMath;
|
||||
#trace( $wgSmjUseCdn );
|
||||
#exit;
|
||||
$wgOut->addModules( 'ext.SimpleMathJax' );
|
||||
// MobileFrontend requires explicit cloned modules targeting mobile
|
||||
$wgOut->addModules( $smjModule . ".mobile" );
|
||||
$wgOut->addJsConfigVars( 'wgSmjSize', $wgSmjSize );
|
||||
$wgOut->addModules( 'ext.SimpleMathJax.mobile' );
|
||||
|
||||
$wgOut->addJsConfigVars( 'wgSmjUseCdn', $wgSmjUseCdn );
|
||||
$wgOut->addJsConfigVars( 'wgSmjScale', $wgSmjScale );
|
||||
$wgOut->addJsConfigVars( 'wgSmjUseChem', $wgSmjUseChem );
|
||||
$wgOut->addJsConfigVars( 'wgSmjShowMathMenu', $wgSmjShowMathMenu );
|
||||
$wgSmjInlineMath[] = ["[math]","[/math]"];
|
||||
$wgOut->addJsConfigVars( 'wgSmjInlineMath', $wgSmjInlineMath );
|
||||
$wgOut->addJsConfigVars( 'wgSmjExtraInlineMath', $wgSmjExtraInlineMath );
|
||||
$wgOut->addJsConfigVars( 'wgSmjDisplayMath', $wgSmjDisplayMath );
|
||||
|
||||
$parser->setHook( 'math', __CLASS__ . '::renderMath' );
|
||||
if( $wgSmjUseChem ) $parser->setHook( 'chem', __CLASS__ . '::renderChem' );
|
||||
}
|
||||
|
@ -30,12 +31,11 @@ class SimpleMathJax {
|
|||
}
|
||||
|
||||
public static function renderChem($tex, array $args, Parser $parser, PPFrame $frame ) {
|
||||
$tex = '\ce{'.$tex.'}';
|
||||
return self::renderTex($tex, $parser);
|
||||
return self::renderTex('\ce{'.$tex.'}', $parser);
|
||||
}
|
||||
|
||||
private static function renderTex($tex, $parser) {
|
||||
return ["<span style='opacity:0.5'>[math]${tex}[/math]</span>", 'markerType'=>'nowiki'];
|
||||
return ["<span style='opacity:.5'>[math]${tex}[/math]</span>", 'markerType'=>'nowiki'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
{
|
||||
"name": "SimpleMathJax",
|
||||
"version": "0.7.4",
|
||||
"author": [
|
||||
"jmnote", "vedmaka", "jamesmontalvo3", "badshah400"
|
||||
],
|
||||
"version": "0.7.5",
|
||||
"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+",
|
||||
|
@ -13,21 +11,21 @@
|
|||
},
|
||||
"callback": "SimpleMathJax::onRegistration",
|
||||
"config": {
|
||||
"SmjSize": 110,
|
||||
"SmjUseCDN": true,
|
||||
"SmjUseChem": true,
|
||||
"SmjShowMathMenu": false,
|
||||
"SmjInlineMath": [],
|
||||
"SmjDisplayMath": []
|
||||
"SmjUseCdn": {"value":false, "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"}
|
||||
},
|
||||
"ResourceModules": {
|
||||
"ext.SmjCDN": {"scripts":["ext.SmjCDN.js"], "targets":["mobile","desktop"] },
|
||||
"ext.SmjLocal": {"scripts":["ext.SmjLocal.js"], "targets":["mobile","desktop"] }
|
||||
"ext.SimpleMathJax": {
|
||||
"scripts": ["resources/ext.SimpleMathJax.js"]
|
||||
}
|
||||
},
|
||||
"ResourceFileModulePaths": {
|
||||
"localBasePath": "modules",
|
||||
"remoteExtPath": "SimpleMathJax/modules"
|
||||
"localBasePath": "",
|
||||
"remoteExtPath": "SimpleMathJax/resources"
|
||||
},
|
||||
"manifest_version": 1
|
||||
"manifest_version": 2
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit c8292351190ce249f7143f224dbe7a190c8228fe
|
|
@ -1,17 +0,0 @@
|
|||
$.getScript( '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js',
|
||||
function () {
|
||||
var extensions = ["tex2jax.js","TeX/AMSmath.js","TeX/autoload-all.js"];
|
||||
if( mw.config.get('wgSmjUseChem') ) extensions.push("TeX/mhchem.js");
|
||||
MathJax.Hub.Config({
|
||||
messageStyle: "none",
|
||||
extensions: extensions,
|
||||
jax: ["input/TeX", "output/HTML-CSS"],
|
||||
showMathMenu: mw.config.get('wgSmjShowMathMenu'),
|
||||
"HTML-CSS": { scale: mw.config.get('wgSmjSize') },
|
||||
tex2jax: { inlineMath: mw.config.get('wgSmjInlineMath') }
|
||||
});
|
||||
MathJax.Hub.Queue(function() {
|
||||
$(".MathJax").parent().css('opacity',1);
|
||||
});
|
||||
}
|
||||
);
|
|
@ -1,19 +0,0 @@
|
|||
$.getScript( mw.config.get('wgExtensionAssetsPath') + '/SimpleMathJax/modules/MathJax/MathJax.js',
|
||||
function () {
|
||||
MathJax.Ajax.config.root = mw.config.get('wgExtensionAssetsPath') + '/SimpleMathJax/modules/MathJax';
|
||||
var extensions = ["tex2jax.js","TeX/AMSmath.js","TeX/autoload-all.js"];
|
||||
if( mw.config.get('wgSmjUseChem') ) extensions.push("TeX/mhchem.js");
|
||||
MathJax.Hub.Config({
|
||||
messageStyle: "none",
|
||||
extensions: extensions,
|
||||
jax: ["input/TeX", "output/HTML-CSS"],
|
||||
showMathMenu: mw.config.get('wgSmjShowMathMenu'),
|
||||
"HTML-CSS": { scale: mw.config.get('wgSmjSize') },
|
||||
tex2jax: { inlineMath: mw.config.get('wgSmjInlineMath') }
|
||||
});
|
||||
MathJax.Hub.Queue(function() {
|
||||
$(".MathJax").parent().css('opacity',1);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
window.MathJax = {
|
||||
tex: {
|
||||
inlineMath: mw.config.get('wgSmjExtraInlineMath').concat([['[math]','[/math]']]),
|
||||
displayMath: mw.config.get('wgSmjDisplayMath'),
|
||||
packages: mw.config.get('wgSmjUseChem') ? {'[+]': ['mhchem']} : {}
|
||||
},
|
||||
chtml: {
|
||||
scale: mw.config.get('wgSmjScale')
|
||||
},
|
||||
loader: {
|
||||
load: mw.config.get('wgSmjUseChem') ? ['[tex]/mhchem'] : []
|
||||
},
|
||||
startup: {
|
||||
pageReady: () => {
|
||||
return MathJax.startup.defaultPageReady().then(() => {
|
||||
$(".MathJax").parent().css('opacity',1);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
(function () {
|
||||
console.log( window.MathJax );
|
||||
var script = document.createElement('script');
|
||||
script.src = mw.config.get('wgSmjUseCdn') ? 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'
|
||||
: mw.config.get('wgExtensionAssetsPath') + '/SimpleMathJax/resources/MathJax/es5/tex-chtml.js';
|
||||
script.async = true;
|
||||
document.head.appendChild(script);
|
||||
})();
|
正在加载...
在新工单中引用