diff --git a/SimpleMathJax.class.php b/SimpleMathJax.class.php
deleted file mode 100644
index 121be1ef..00000000
--- a/SimpleMathJax.class.php
+++ /dev/null
@@ -1,46 +0,0 @@
-setHook( 'math', 'SimpleMathJax::renderMath' );
- if( $wgSimpleMathJaxChem )
- $wgParser->setHook( 'chem', 'SimpleMathJax::renderChem' );
- }
-
- static function renderMath($tex) {
- $tex = str_replace('\>', '\;', $tex);
- $tex = str_replace('<', '\lt ', $tex);
- $tex = str_replace('>', '\gt ', $tex);
- return self::renderTex($tex);
- }
-
- static function renderChem($tex) {
- $tex = '\ce{'.$tex.'}';
- return self::renderTex($tex);
- }
-
- static function renderTex($tex) {
- return ["[math]${tex}[/math]", 'markerType'=>'nowiki'];
- }
-
- static function addScripts( $out ) {
- global $wgSimpleMathJaxSize, $wgSimpleMathJaxChem, $wgSimpleMathJaxJs, $wgSimpleMathJaxChemJs;
-
- if( !$wgSimpleMathJaxJs )
- $wgSimpleMathJaxJs = '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
- if( !$wgSimpleMathJaxChemJs )
- $wgSimpleMathJaxChemJs = '//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/extensions/TeX/mhchem.js';
- $out->addScript( <<.mathjax-wrapper{display:none;font-size:${wgSimpleMathJaxSize}%;}.MathJax_Display{display:inline !important;}
-
-
-HEREDOC
-);
- if( $wgSimpleMathJaxChem )
- $out->addScript( "" );
- return true;
- }
-}
diff --git a/SimpleMathJax.php b/SimpleMathJax.php
index a40774c7..e6da0a5d 100644
--- a/SimpleMathJax.php
+++ b/SimpleMathJax.php
@@ -1,32 +1,11 @@
__FILE__,
- 'name' => 'SimpleMathJax',
- 'version' => '0.5',
- 'author' => 'jmnote, vedmaka, jamesmontalvo3, badshah400',
- 'description' => 'render TeX between and ',
- 'url' => '//www.mediawiki.org/wiki/Extension:SimpleMathJax'
-);
-
-// Register class
-$dir = dirname(__FILE__) . '/';
-$wgAutoloadClasses['SimpleMathJax'] = $dir.'SimpleMathJax.class.php';
-
-$wgExtensionFunctions[] = 'SimpleMathJax::init';
-$wgHooks['BeforePageDisplay'][] = 'SimpleMathJax::addScripts';
+if ( function_exists( 'wfLoadExtension' ) ) {
+ wfLoadExtension( 'SimpleMathJax' );
+ wfWarn(
+ 'Deprecated PHP entry point used for SimpleMathJax extension. Please use wfLoadExtension ' .
+ 'instead, see https://www.mediawiki.org/wiki/Extension_registration for more details.'
+ );
+ return true;
+} else {
+ die( 'This version of the SimpleMathJax extension requires MediaWiki 1.25+' );
+}
diff --git a/SimpleMathJax_body.php b/SimpleMathJax_body.php
new file mode 100644
index 00000000..c8a7fb6f
--- /dev/null
+++ b/SimpleMathJax_body.php
@@ -0,0 +1,37 @@
+addJsConfigVars( 'wgSimpleMathJaxSize', $wgSimpleMathJaxSize );
+ $wgOut->addModules( 'ext.SimpleMathJax' );
+ }
+
+ public static function onParserFirstCallInit( Parser $parser ) {
+ $parser->setHook( 'math', __CLASS__ . '::renderMath' );
+ $parser->setHook( 'chem', __CLASS__ . '::renderChem' );
+ }
+
+ public static function renderMath($tex) {
+ $tex = str_replace('\>', '\;', $tex);
+ $tex = str_replace('<', '\lt ', $tex);
+ $tex = str_replace('>', '\gt ', $tex);
+ return self::renderTex($tex);
+ }
+
+ public static function renderChem($tex) {
+ $tex = '\ce{'.$tex.'}';
+ return self::renderTex($tex);
+ }
+
+ public static function renderTex($tex) {
+ return ["[math]${tex}[/math]", 'markerType'=>'nowiki'];
+ }
+
+}
diff --git a/ext.SimpleMathJax.js b/ext.SimpleMathJax.js
new file mode 100644
index 00000000..ccc623b5
--- /dev/null
+++ b/ext.SimpleMathJax.js
@@ -0,0 +1,12 @@
+MathJax.Ajax.config.root = mw.config.get('wgExtensionAssetsPath') + '/SimpleMathJax/MathJax';
+MathJax.Hub.Config({
+ "messageStyle": "none",
+ "HTML-CSS": { scale: mw.config.get('wgSimpleMathJaxSize') },
+ "tex2jax": {
+ "preview": "none",
+ "inlineMath": [["[math]","[/math]"]]
+ }
+});
+MathJax.Hub.Queue( function() {
+ $(".MathJax").parent().show();
+});
diff --git a/extension.json b/extension.json
new file mode 100644
index 00000000..e7999e97
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,32 @@
+{
+ "name": "SimpleMathJax",
+ "version": "0.6",
+ "author": [
+ "jmnote", "vedmaka", "jamesmontalvo3", "badshah400"
+ ],
+ "url": "http://www.mediawiki.org/wiki/Extension:SimpleMathJax",
+ "description": "render TeX between <math>
and </math>
",
+ "license-name": "GPL-2.0+",
+ "type": "parserhook",
+ "AutoloadClasses": {
+ "SimpleMathJax": "SimpleMathJax_body.php"
+ },
+ "callback": "SimpleMathJax::onRegistration",
+ "config": {
+ "SimpleMathJaxSize": 125
+ },
+ "ResourceModules": {
+ "ext.SimpleMathJax": {
+ "scripts": [
+ "MathJax/MathJax.js",
+ "ext.SimpleMathJax.js",
+ "MathJax/config/TeX-AMS-MML_HTMLorMML.js",
+ "MathJax-mhchem/mhchem.js"
+ ]
+ }
+ },
+ "ResourceFileModulePaths": {
+ "localBasePath": "",
+ "remoteExtPath": "SimpleMathJax"
+ }
+}