Fix: Don't render ' inside LR structures

$\left(a\right)'$ produced rendered MathML output that
looked like $\left(a'\right)'$.

* Remove the deriv (') state when rendering the element
within the brackets.

Bug: T381102
Change-Id: Id7f192c1f6b7bf4109e735e393e2546e5a39efd7
This commit is contained in:
physikerwelt 2024-11-29 01:13:15 +01:00
parent d50764230c
commit 0781935316
No known key found for this signature in database
GPG key ID: FCC793EFFA5FB13C
3 changed files with 20 additions and 1 deletions

View file

@ -74,7 +74,8 @@ class Lr extends TexNode {
$moRight = new MMLmo( TexClass::CLOSE, $rightAttrs );
$right = $moRight->encapsulateRaw( $this->right );
}
// Don't apply outer ' inside the LR structure
unset( $state['deriv'] );
$inner = $this->getArg()->renderMML( [], $state );
$mrow = new MMLmrow( TexClass::INNER );
return $mrow->encapsulateRaw(

View file

@ -56,4 +56,17 @@ class LrTest extends MediaWikiUnitTestCase {
'Should extract identifiers' );
}
public function testRenderA() {
$n = new Lr( '(', ')', new TexArray( new Literal( 'A' ) ) );
$mml = $n->renderMML();
$this->assertStringContainsString( 'A</mi>', $mml );
$this->assertStringContainsString( ')</mo>', $mml );
}
public function testRenderADeriv() {
$n = new Lr( '(', ')', new TexArray( new Literal( 'A' ) ) );
$mml = $n->renderMML( [], [ 'deriv' => 1 ] );
$this->assertStringNotContainsString( '&#x2032;</mo>', $mml );
}
}

View file

@ -151,4 +151,9 @@ class TexArrayTest extends MediaWikiUnitTestCase {
$this->assertEquals( $custom, $res[0] );
}
public function testRenderADeriv() {
$n = new TexArray( new Literal( 'A' ) );
$mml = $n->renderMML( [], [ 'deriv' => 1 ] );
$this->assertStringContainsString( '&#x2032;</mo>', $mml );
}
}