mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-18 02:20:46 +00:00
Add options to the math tag
* id: Allows to name equations and deep link to equations * forcemathmode: Allows to override the user defined rendering mode. This feature is useful for help pages and discussions about rendering. * type: support for MathML and asciimath input required for MediaWiki instances that want to incorporate MathML sources like for instance pubmed Change-Id: I615c7f1a5762e9e662937b70953fb873309d4c07
This commit is contained in:
parent
d928de94e5
commit
04ce4a02c7
3
Math.php
3
Math.php
|
@ -191,6 +191,9 @@ $wgMathDisableTexFilter = false;
|
||||||
|
|
||||||
/** Stores debug information in the database and provides more detailed debug output */
|
/** Stores debug information in the database and provides more detailed debug output */
|
||||||
$wgMathDebug = false;
|
$wgMathDebug = false;
|
||||||
|
|
||||||
|
/** @var boolean $wgMathEnableExperimentalInputFormats enables experimental MathML and AsciiMath input format support */
|
||||||
|
$wgMathEnableExperimentalInputFormats = false;
|
||||||
////////// end of config settings.
|
////////// end of config settings.
|
||||||
|
|
||||||
$wgExtensionFunctions[] = 'MathHooks::setup';
|
$wgExtensionFunctions[] = 'MathHooks::setup';
|
||||||
|
|
|
@ -117,7 +117,7 @@ abstract class MathRenderer {
|
||||||
* @return MathRenderer appropriate renderer for mode
|
* @return MathRenderer appropriate renderer for mode
|
||||||
*/
|
*/
|
||||||
public static function getRenderer( $tex, $params = array(), $mode = MW_MATH_PNG ) {
|
public static function getRenderer( $tex, $params = array(), $mode = MW_MATH_PNG ) {
|
||||||
global $wgDefaultUserOptions, $wgMathValidModes;
|
global $wgDefaultUserOptions, $wgMathValidModes, $wgMathEnableExperimentalInputFormats;
|
||||||
$mathStyle = null;
|
$mathStyle = null;
|
||||||
if ( isset( $params['display'] ) ) {
|
if ( isset( $params['display'] ) ) {
|
||||||
$layoutMode = $params['display'];
|
$layoutMode = $params['display'];
|
||||||
|
@ -139,9 +139,23 @@ abstract class MathRenderer {
|
||||||
$tex = '{\textstyle ' . $tex . '}';
|
$tex = '{\textstyle ' . $tex . '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$id = null;
|
||||||
|
if ( isset( $params['id'] ) ) {
|
||||||
|
$id = $params['id'];
|
||||||
|
}
|
||||||
|
if ( isset( $params['forcemathmode'] ) ) {
|
||||||
|
$mode = $params['forcemathmode'];
|
||||||
|
}
|
||||||
if ( !in_array( $mode, $wgMathValidModes ) ) {
|
if ( !in_array( $mode, $wgMathValidModes ) ) {
|
||||||
$mode = $wgDefaultUserOptions['math'];
|
$mode = $wgDefaultUserOptions['math'];
|
||||||
}
|
}
|
||||||
|
if ( $wgMathEnableExperimentalInputFormats === true && $mode == MW_MATH_MATHML && isset( $params['type'] ) ) {
|
||||||
|
// Support of MathML input (experimental)
|
||||||
|
// Currently support for mode MW_MATH_MATHML only
|
||||||
|
if( !in_array( $params['type'], array( 'pmml', 'ascii' ) ) ) {
|
||||||
|
unset( $params['type'] );
|
||||||
|
}
|
||||||
|
}
|
||||||
switch ( $mode ) {
|
switch ( $mode ) {
|
||||||
case MW_MATH_MATHJAX:
|
case MW_MATH_MATHJAX:
|
||||||
case MW_MATH_SOURCE:
|
case MW_MATH_SOURCE:
|
||||||
|
|
Loading…
Reference in a new issue