From c61b8becac714ca4d6c694f48c736fb5753a8977 Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Wed, 8 Oct 2014 17:37:28 -0700 Subject: [PATCH] Use radio buttons only for math mode selection While the combination of all redering modes, might be useful for some power users it will confuse the average user and makes bug reporting harder. Therefore, source rendering on the server side is used when MathJax is enabled on the client side. Change-Id: I05a20d7c2298115dbf0429db6c107e8132cc15ff --- Math.hooks.php | 17 ++++++----------- Math.php | 15 ++------------- i18n/en.json | 9 +++++---- i18n/qqq.json | 1 + modules/ext.math.mathjax.enabler.js | 4 ---- 5 files changed, 14 insertions(+), 32 deletions(-) diff --git a/Math.hooks.php b/Math.hooks.php index e2ef1db..8fadacb 100644 --- a/Math.hooks.php +++ b/Math.hooks.php @@ -92,7 +92,7 @@ class MathHooks { * @return array */ static function mathTagHook( $content, $attributes, $parser ) { - global $wgUseMathJax; + global $wgMathDisableTexFilter; if ( trim( $content ) === '' ) { // bug 8372 return ''; @@ -130,7 +130,7 @@ class MathHooks { &$renderedMath, $parser->getTitle()->getArticleID(), $parser->nextLinkID() ) );// Enables indexing of math formula - if ( $wgUseMathJax ) { + if ( $mode == MW_MATH_MATHJAX || $mode == MW_MATH_LATEXML_JAX ) { $parser->getOutput()->addModules( array( 'ext.math.mathjax.enabler' ) ); } $parser->getOutput()->addModuleStyles( array( 'ext.math.styles' ) ); @@ -152,20 +152,13 @@ class MathHooks { * @return Boolean: true */ static function onGetPreferences( $user, &$defaultPreferences ) { - global $wgUseMathJax, $wgMathValidModes, $wgDefaultUserOptions; + global $wgMathValidModes, $wgDefaultUserOptions; $defaultPreferences['math'] = array( 'type' => 'radio', 'options' => array_flip( self::getMathNames() ), 'label' => ' ', 'section' => 'rendering/math', ); - if ( $wgUseMathJax ) { - $defaultPreferences['mathJax'] = array( - 'type' => 'toggle', - 'label-message' => 'mw_math_mathjax', - 'section' => 'rendering/math', - ); - } // If the default option is not in the valid options the // user interface throws an exception (BUG 64844) if ( ! in_array( $wgDefaultUserOptions['math'] , $wgMathValidModes ) ){ @@ -187,7 +180,9 @@ class MathHooks { MW_MATH_SOURCE => 'mw_math_source', MW_MATH_PNG => 'mw_math_png', MW_MATH_MATHML => 'mw_math_mathml', - MW_MATH_LATEXML => 'mw_math_latexml' + MW_MATH_LATEXML => 'mw_math_latexml', + MW_MATH_LATEXML_JAX => 'mw_math_latexml_jax', + MW_MATH_MATHJAX => 'mw_math_mathjax' ); $names = array(); foreach ( $wgMathValidModes as $mode ) { diff --git a/Math.php b/Math.php index 339810b..bfa3685 100644 --- a/Math.php +++ b/Math.php @@ -45,6 +45,7 @@ define( 'MW_MATH_MODERN', 4 ); /// @deprecated define( 'MW_MATH_MATHML', 5 ); define( 'MW_MATH_MATHJAX', 6 ); /// @deprecated define( 'MW_MATH_LATEXML', 7 ); /// new in 1.22 +define( 'MW_MATH_LATEXML_JAX', 8 ); /// new in 1.22 /**@}*/ /**@{ @@ -58,15 +59,13 @@ define( 'MW_MATHSTYLE_INLINE', 2 ); // small operators inline /**@}*/ /**@var array defines the mode allowed on the server */ -$wgMathValidModes = array( MW_MATH_PNG, MW_MATH_SOURCE, MW_MATH_MATHML ); +$wgMathValidModes = array( MW_MATH_PNG, MW_MATH_SOURCE, MW_MATH_MATHML, MW_MATH_MATHJAX ); /* * The default rendering mode for anonymous users. * Valid options are defined in $wgMathValidModes. */ $wgDefaultUserOptions['math'] = MW_MATH_PNG; -/** @var boolean $wgDefaultUserOptions['mathJax'] determines if client-side MathJax is enabled by default */ -$wgDefaultUserOptions['mathJax'] = false; /** Location of the texvc binary */ $wgTexvc = __DIR__ . '/math/texvc'; @@ -117,16 +116,6 @@ $wgMathFileBackend = false; */ $wgMathDirectory = false; -/** - * Enables the option to use MathJax library to do client-side math rendering - * when JavaScript is available. In supporting browsers this makes nice output - * that's scalable for zooming, printing, and high-resolution displays, even if - * the browsers do not support HTML5 (i.e. MathML). - * - * @todo Rename to $wgMathJax - */ -$wgUseMathJax = false; - /** * The url of the mathoid server. * see http://www.formulasearchengine.com/mathoid diff --git a/i18n/en.json b/i18n/en.json index adf1f43..5fb32f5 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -6,11 +6,12 @@ "math_sample": "Insert formula here", "math_tip": "Mathematical formula (LaTeX)", "prefs-math": "Math", - "mw_math_png": "Always render PNG", - "mw_math_source": "Leave it as TeX (for text browsers)", - "mw_math_mathjax": "MathJax (experimental)", - "mw_math_mathml": "MathML with SVG or PNG fallback (experimental)", + "mw_math_png": "PNG images", + "mw_math_source": "TeX source (for text browsers)", + "mw_math_mathjax": "Client-side MathJax (slow, enhance rendering for some browsers & accessibility tools)", + "mw_math_mathml": "MathML with SVG or PNG fallback (recommended for modern browsers & accessibility tools)", "mw_math_latexml": "LaTeXML (experimental; uses MathML)", + "mw_math_latexml_jax": "LaTeXML with client-side MathJax (experimental; uses MathML)", "math_failure": "Failed to parse", "math_unknown_error": "unknown error", "math_unknown_function": "unknown function \"$1\"", diff --git a/i18n/qqq.json b/i18n/qqq.json index 20a0fb0..371d290 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -20,6 +20,7 @@ "mw_math_mathjax": "Used as label for mathjax radio button.\n\nSee also:\n* {{msg-mw|Mw math png}}\n* {{msg-mw|Mw math source}}\n* {{msg-mw|Mw math latexml}}", "mw_math_mathml": "Used as label for MathML radio button.\n\nSee also:\n* {{msg-mw|Mw math png}}\n* {{msg-mw|Mw math source}}\n* {{msg-mw|Mw math latexml}}", "mw_math_latexml": "Used as label for latexml radio button.\n\nSee also:\n* {{msg-mw|Mw math png}}\n* {{msg-mw|Mw math source}}\n* {{msg-mw|Mw math mathjax}}", + "mw_math_latexml_jax": "Used as label for latexml (with mathjax enabled) radio button.\n\nSee also:\n* {{msg-mw|Mw math png}}\n* {{msg-mw|Mw math source}}\n* {{msg-mw|Mw math mathjax}}\n* {{msg-mw|Mw math latexml}}", "math_failure": "Used as error message.\n\nThis message is followed by \"(\", Error message(*1), Additional message, \"): \" and Source code.\n\n(*1) The error message is any one of the following messages:\n* {{msg-mw|Math unknown error}}\n* {{msg-mw|Math unknown function}}\n* {{msg-mw|Math lexing error}}\n* {{msg-mw|Math syntax error}}\n* {{msg-mw|Math image error}}\n* {{msg-mw|Math bad tmpdir}}\n* {{msg-mw|Math bad output}}\n* {{msg-mw|Math notexvc}}\n* {{msg-mw|Math notexvccheck}}\n* {{msg-mw|Math output error}}\n* {{msg-mw|Math timeout}}\n* {{msg-mw|Math invalidresponse}}\n* {{msg-mw|Math invalidxml}}\n* {{msg-mw|Math invalidjson}}", "math_unknown_error": "Used as error message for unknown texvc error.\n\nThis message follows the message {{msg-mw|Math failure}}.\n{{Identical|Unknown error}}", "math_unknown_function": "Used as error message when texvc encounters an unknown function.\n\nPreceded by the message {{msg-mw|Math failure}}.\n\nParameters:\n* $1 - name of unknown function", diff --git a/modules/ext.math.mathjax.enabler.js b/modules/ext.math.mathjax.enabler.js index 17d2ae0..47cdf8a 100644 --- a/modules/ext.math.mathjax.enabler.js +++ b/modules/ext.math.mathjax.enabler.js @@ -5,10 +5,6 @@ ( function ( mw, $ ) { 'use strict'; - if( ! mw.user.options.get( 'mathJax' ) ) { - return true; - } - if ( typeof mathJax === 'undefined' ) { window.mathJax = {}; }