From 32acbe3f4754f94e0d122148533b725e870420b5 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Sat, 27 Apr 2013 15:28:46 +0200 Subject: [PATCH] MathJax: Allow user to configure MathJax The user can provide his own mathJax.config object. Supersedes: https://gerrit.wikimedia.org/r/61182 PS2: Add relevant info for this feature to README Bug: 35478 Change-Id: I97800317366aafcaad87ecf6644e9417c698c5da --- README | 13 +++++++++ modules/ext.math.mathjax.enabler.js | 42 +++++++++++++++-------------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/README b/README index 54123a8..8846d84 100644 --- a/README +++ b/README @@ -7,6 +7,19 @@ This version (for MediaWiki 1.19) has some changes since previous versions: See the README in the math subdirectory for more info on setting up the low-level conversion tools. +MathJax configuration: +Client-side configuration of MathJax can be done by specifying a mathJax.config +table, which takes a table as described in: +http://docs.mathjax.org/en/v1.1-latest/options/index.html#configuration + +Example: +if ( typeof mathJax === 'undefined' ) { + mathJax = {}; + mathJax.config = { + showProcessingMessages: true + }; +} + For testing your installation run php tests/phpunit/phpunit.php extensions/Math/tests/ from your MediWiki home path. diff --git a/modules/ext.math.mathjax.enabler.js b/modules/ext.math.mathjax.enabler.js index e1343a8..faa5b89 100644 --- a/modules/ext.math.mathjax.enabler.js +++ b/modules/ext.math.mathjax.enabler.js @@ -11,27 +11,29 @@ mathJax.loaded = false; - mathJax.Config = function () { - MathJax.Hub.Config({ - root: mw.config.get('wgExtensionAssetsPath') + '/Math/modules/MathJax', - config: ['TeX-AMS-texvc_HTML.js'], - 'v1.0-compatible': false, - styles: { - '.mtext': { - 'font-family': 'sans-serif ! important', - 'font-size': '80%' - } - }, - displayAlign: 'left', - menuSettings: { - zoom: 'Click' - }, - 'HTML-CSS': { - imageFont: null, - availableFonts: ['TeX'] + mathJax.config = $.extend( true, { + root: mw.config.get('wgExtensionAssetsPath') + '/Math/modules/MathJax', + config: ['TeX-AMS-texvc_HTML.js'], + 'v1.0-compatible': false, + styles: { + '.mtext': { + 'font-family': 'sans-serif ! important', + 'font-size': '80%' } - }); - MathJax.OutputJax.fontDir = mathJax.fontDir = mw.config.get('wgExtensionAssetsPath') + '/Math/modules/MathJax/fonts'; + }, + displayAlign: 'left', + menuSettings: { + zoom: 'Click' + }, + 'HTML-CSS': { + imageFont: null, + availableFonts: ['TeX'] + } + }, mathJax.config ); + + mathJax.Config = function () { + MathJax.Hub.Config( mathJax.config ); + MathJax.OutputJax.fontDir = mw.config.get('wgExtensionAssetsPath') + '/Math/modules/MathJax/fonts'; }; mathJax.Load = function () {