diff --git a/src/TexVC/Nodes/Literal.php b/src/TexVC/Nodes/Literal.php index a734d3c7a..1751a8ed8 100644 --- a/src/TexVC/Nodes/Literal.php +++ b/src/TexVC/Nodes/Literal.php @@ -30,6 +30,11 @@ class Literal extends TexNode { } public function renderMML( $arguments = [], $state = [] ) { + if ( $this->arg === " " ) { + // Fixes https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/961711 + // And they creation of empty mo elements. + return ""; + } if ( is_numeric( $this->arg ) ) { $mn = new MMLmn( "", $arguments ); return $mn->encapsulateRaw( $this->arg ); diff --git a/tests/phpunit/InputCheck/LocalCheckerTest.php b/tests/phpunit/InputCheck/LocalCheckerTest.php index 2187cdee7..4325d0630 100644 --- a/tests/phpunit/InputCheck/LocalCheckerTest.php +++ b/tests/phpunit/InputCheck/LocalCheckerTest.php @@ -117,7 +117,7 @@ class LocalCheckerTest extends MediaWikiIntegrationTestCase { public function testRunChecks() { $fakeContent = [ 'status' => '+', - 'mathml' => 'sinx2', + 'mathml' => 'sinx2', 'output' => '\\sin x^{2}' ]; $checker = new LocalChecker( WANObjectCache::newEmpty(), '\sin x^2', 'tex' ); diff --git a/tests/phpunit/unit/TexVC/MMLRenderTest.php b/tests/phpunit/unit/TexVC/MMLRenderTest.php index 26cd355ee..8a8975c9d 100644 --- a/tests/phpunit/unit/TexVC/MMLRenderTest.php +++ b/tests/phpunit/unit/TexVC/MMLRenderTest.php @@ -26,6 +26,13 @@ class MMLRenderTest extends MediaWikiUnitTestCase { $this->assertStringContainsString( "munderover", $mathMLtexVC ); } + public function testScriptAlignment() { + $input = "\log_{10} f"; + $mathMLtexVC = $this->generateMML( $input ); + $this->assertStringNotContainsString( "", $mathMLtexVC ); + $this->assertStringContainsString( "", $mathMLtexVC ); + } + public function testNotOperatorname() { $input = "\\not\operatorname{R}"; $mathMLtexVC = $this->generateMML( $input );