mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-13 17:56:59 +00:00
Make native MathML rendering default
* Add native to default valid modes. * Remove old Mathoid mode from the default valid modes. * Set native as the default choice, replacing Mathoid. * Adjust fallback mechanism. Bug: T373705 Change-Id: Ie6412623577e3f954c1302417d1b1b667f88863e
This commit is contained in:
parent
7574e7acc0
commit
8cce9d88c1
|
@ -27,7 +27,7 @@
|
||||||
"MediaWiki\\Extension\\Math\\WikiTexVC\\MMLmappings\\Util\\MMLComparator": "tests/phpunit/unit/WikiTexVC/MMLComparator.php"
|
"MediaWiki\\Extension\\Math\\WikiTexVC\\MMLmappings\\Util\\MMLComparator": "tests/phpunit/unit/WikiTexVC/MMLComparator.php"
|
||||||
},
|
},
|
||||||
"DefaultUserOptions": {
|
"DefaultUserOptions": {
|
||||||
"math": "mathml",
|
"math": "native",
|
||||||
"math-popups": "1"
|
"math-popups": "1"
|
||||||
},
|
},
|
||||||
"ExtensionMessagesFiles": {
|
"ExtensionMessagesFiles": {
|
||||||
|
@ -161,7 +161,8 @@
|
||||||
"description": "To access this at run-time, use MathConfig::getValidRenderingModes(). Do not use the non-normalized configuration directly.",
|
"description": "To access this at run-time, use MathConfig::getValidRenderingModes(). Do not use the non-normalized configuration directly.",
|
||||||
"value": [
|
"value": [
|
||||||
"source",
|
"source",
|
||||||
"mathml"
|
"native",
|
||||||
|
"mathjax"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"MathEnableWikibaseDataType": {
|
"MathEnableWikibaseDataType": {
|
||||||
|
|
|
@ -162,7 +162,7 @@ class MathConfig {
|
||||||
* @param string $default rendering mode to use by default on unrecognized input
|
* @param string $default rendering mode to use by default on unrecognized input
|
||||||
* @return string one of the self::MODE_* constants.
|
* @return string one of the self::MODE_* constants.
|
||||||
*/
|
*/
|
||||||
public static function normalizeRenderingMode( $mode, string $default = self::MODE_MATHML ): string {
|
public static function normalizeRenderingMode( $mode, string $default = self::MODE_NATIVE_MML ): string {
|
||||||
if ( is_int( $mode ) ) {
|
if ( is_int( $mode ) ) {
|
||||||
$userOptionToMode = array_flip( self::MODES_TO_USER_OPTIONS );
|
$userOptionToMode = array_flip( self::MODES_TO_USER_OPTIONS );
|
||||||
return $userOptionToMode[$mode] ?? $default;
|
return $userOptionToMode[$mode] ?? $default;
|
||||||
|
|
|
@ -53,6 +53,8 @@ class MathConfigTest extends TestCase {
|
||||||
yield 'mathml user option' => [ 5, MathConfig::MODE_MATHML ];
|
yield 'mathml user option' => [ 5, MathConfig::MODE_MATHML ];
|
||||||
yield 'latexml user option' => [ 7, MathConfig::MODE_LATEXML ];
|
yield 'latexml user option' => [ 7, MathConfig::MODE_LATEXML ];
|
||||||
yield 'native user option' => [ 8, MathConfig::MODE_NATIVE_MML ];
|
yield 'native user option' => [ 8, MathConfig::MODE_NATIVE_MML ];
|
||||||
|
yield 'mathjax option' => [ 9, MathConfig::MODE_NATIVE_JAX ];
|
||||||
|
|
||||||
yield 'source string' => [ 'source', MathConfig::MODE_SOURCE ];
|
yield 'source string' => [ 'source', MathConfig::MODE_SOURCE ];
|
||||||
yield 'mathml string' => [ 'mathml', MathConfig::MODE_MATHML ];
|
yield 'mathml string' => [ 'mathml', MathConfig::MODE_MATHML ];
|
||||||
yield 'latexml string' => [ 'latexml', MathConfig::MODE_LATEXML ];
|
yield 'latexml string' => [ 'latexml', MathConfig::MODE_LATEXML ];
|
||||||
|
@ -72,14 +74,13 @@ class MathConfigTest extends TestCase {
|
||||||
public function testGetValidRenderingModes() {
|
public function testGetValidRenderingModes() {
|
||||||
$mathConfig = $this->newMathConfig( [
|
$mathConfig = $this->newMathConfig( [
|
||||||
'MathValidModes' => [
|
'MathValidModes' => [
|
||||||
MathConfig::MODE_MATHML,
|
MathConfig::MODE_NATIVE_MML,
|
||||||
5,
|
|
||||||
MathConfig::MODE_SOURCE,
|
MathConfig::MODE_SOURCE,
|
||||||
'this will be converted to mathml' ],
|
'this will be converted to mathml' ],
|
||||||
] );
|
] );
|
||||||
$actualModes = $mathConfig->getValidRenderingModes();
|
$actualModes = $mathConfig->getValidRenderingModes();
|
||||||
$this->assertCount( 2, $actualModes );
|
$this->assertCount( 2, $actualModes );
|
||||||
$this->assertContains( MathConfig::MODE_MATHML, $actualModes );
|
$this->assertContains( MathConfig::MODE_NATIVE_MML, $actualModes );
|
||||||
$this->assertContains( MathConfig::MODE_SOURCE, $actualModes );
|
$this->assertContains( MathConfig::MODE_SOURCE, $actualModes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue