mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 23:25:02 +00:00
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
This commit is contained in:
parent
209f3218ad
commit
c61b8becac
|
@ -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 ) {
|
||||
|
|
15
Math.php
15
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
|
||||
|
|
|
@ -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\"",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
( function ( mw, $ ) {
|
||||
'use strict';
|
||||
|
||||
if( ! mw.user.options.get( 'mathJax' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( typeof mathJax === 'undefined' ) {
|
||||
window.mathJax = {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue