From 8cce9d88c1b635e2753b95bae5fbe32cf19fa74b Mon Sep 17 00:00:00 2001 From: physikerwelt Date: Fri, 30 Aug 2024 19:35:39 +0200 Subject: [PATCH] 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 --- extension.json | 5 +++-- src/MathConfig.php | 2 +- tests/phpunit/unit/MathConfigTest.php | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/extension.json b/extension.json index 664827dea..b16b8f9e9 100644 --- a/extension.json +++ b/extension.json @@ -27,7 +27,7 @@ "MediaWiki\\Extension\\Math\\WikiTexVC\\MMLmappings\\Util\\MMLComparator": "tests/phpunit/unit/WikiTexVC/MMLComparator.php" }, "DefaultUserOptions": { - "math": "mathml", + "math": "native", "math-popups": "1" }, "ExtensionMessagesFiles": { @@ -161,7 +161,8 @@ "description": "To access this at run-time, use MathConfig::getValidRenderingModes(). Do not use the non-normalized configuration directly.", "value": [ "source", - "mathml" + "native", + "mathjax" ] }, "MathEnableWikibaseDataType": { diff --git a/src/MathConfig.php b/src/MathConfig.php index 7bfaa2b76..78a1f0c17 100644 --- a/src/MathConfig.php +++ b/src/MathConfig.php @@ -162,7 +162,7 @@ class MathConfig { * @param string $default rendering mode to use by default on unrecognized input * @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 ) ) { $userOptionToMode = array_flip( self::MODES_TO_USER_OPTIONS ); return $userOptionToMode[$mode] ?? $default; diff --git a/tests/phpunit/unit/MathConfigTest.php b/tests/phpunit/unit/MathConfigTest.php index a7f1cec37..7ccca4916 100644 --- a/tests/phpunit/unit/MathConfigTest.php +++ b/tests/phpunit/unit/MathConfigTest.php @@ -53,6 +53,8 @@ class MathConfigTest extends TestCase { yield 'mathml user option' => [ 5, MathConfig::MODE_MATHML ]; yield 'latexml user option' => [ 7, MathConfig::MODE_LATEXML ]; 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 'mathml string' => [ 'mathml', MathConfig::MODE_MATHML ]; yield 'latexml string' => [ 'latexml', MathConfig::MODE_LATEXML ]; @@ -72,14 +74,13 @@ class MathConfigTest extends TestCase { public function testGetValidRenderingModes() { $mathConfig = $this->newMathConfig( [ 'MathValidModes' => [ - MathConfig::MODE_MATHML, - 5, + MathConfig::MODE_NATIVE_MML, MathConfig::MODE_SOURCE, 'this will be converted to mathml' ], ] ); $actualModes = $mathConfig->getValidRenderingModes(); $this->assertCount( 2, $actualModes ); - $this->assertContains( MathConfig::MODE_MATHML, $actualModes ); + $this->assertContains( MathConfig::MODE_NATIVE_MML, $actualModes ); $this->assertContains( MathConfig::MODE_SOURCE, $actualModes ); }