From 6e0427c2bac4dfd2a200c95a5444a37139e432fb Mon Sep 17 00:00:00 2001 From: Stegmujo Date: Wed, 5 Apr 2023 10:07:04 +0000 Subject: [PATCH] Fix for attributes in named Operator Bug: T315978 Change-Id: I7277d03bae031ffcb2995c097f92c795cc2637dd --- src/TexVC/MMLmappings/BaseParsing.php | 7 +++++++ tests/phpunit/unit/TexVC/MMLRenderTest.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/TexVC/MMLmappings/BaseParsing.php b/src/TexVC/MMLmappings/BaseParsing.php index 0ca3b17ac..f2aff6bfe 100644 --- a/src/TexVC/MMLmappings/BaseParsing.php +++ b/src/TexVC/MMLmappings/BaseParsing.php @@ -529,6 +529,13 @@ class BaseParsing { $args = count( $passedArgs ) >= 1 ? $passedArgs : [ "movablelimits" => "true" ]; $texClass = TexClass::OP; + + // This comes from inf case, preventing 'double'-classtag + if ( isset( $args[Tag::CLASSTAG] ) ) { + $texClass = $args[Tag::CLASSTAG]; + unset( $args[Tag::CLASSTAG] ); + } + if ( $name == "min" || $name == "max" || $name === "gcd" ) { $args["form" ] = "prefix"; $texClass = ""; diff --git a/tests/phpunit/unit/TexVC/MMLRenderTest.php b/tests/phpunit/unit/TexVC/MMLRenderTest.php index 3aa6b1822..6961ee5af 100644 --- a/tests/phpunit/unit/TexVC/MMLRenderTest.php +++ b/tests/phpunit/unit/TexVC/MMLRenderTest.php @@ -186,6 +186,13 @@ class MMLRenderTest extends MediaWikiUnitTestCase { $this->assertStringContainsString( "", $mathMLtexVC ); } + public function testAttributeDuplicate() { + // This checks that there is some non-erronous output caused by double class attributes + $input = "\\mu_{\\operatorname{\\inf}}"; + $mathMLtexVC = $this->generateMML( $input ); + $this->assertStringContainsString( "μ", $mathMLtexVC ); + } + private function generateMML( $input, $chem = false ) { $texVC = new TexVC(); $resultT = $texVC->check( $input, [