Render MathML for atop and choose

Bug: T340024
Change-Id: I19f471645b569db49a64e5dd4c82cfdbac7dbe77
This commit is contained in:
Stegmujo 2023-10-05 10:08:15 +00:00
parent 7dfb557b92
commit bbe6c3df8b
2 changed files with 23 additions and 1 deletions

View file

@ -663,12 +663,13 @@ class BaseParsing {
} }
$inner = ""; $inner = "";
foreach ( $node->getArgs() as $arg ) { foreach ( $node->getArgs() as $arg ) {
if ( $arg === "\\over" ) { if ( is_string( $arg ) && str_contains( $arg, $name ) ) {
continue; continue;
} }
$rendered = $arg instanceof TexNode ? $arg->renderMML() : $arg; $rendered = $arg instanceof TexNode ? $arg->renderMML() : $arg;
$inner .= $mrow->encapsulateRaw( $rendered ); $inner .= $mrow->encapsulateRaw( $rendered );
} }
return $start . $mfrac->encapsulateRaw( $inner ) . $tail; return $start . $mfrac->encapsulateRaw( $inner ) . $tail;
} }

View file

@ -14,6 +14,27 @@ use MediaWikiUnitTestCase;
* @covers \MediaWiki\Extension\Math\TexVC\TexVC * @covers \MediaWiki\Extension\Math\TexVC\TexVC
*/ */
class MMLRenderTest extends MediaWikiUnitTestCase { class MMLRenderTest extends MediaWikiUnitTestCase {
public function testAtop() {
$input = "{ a \atop b }";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "<mfrac linethickness=\"0\">", $mathMLtexVC );
}
public function testChoose() {
$input = "{ a \choose b }";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "<mfrac linethickness=\"0\">", $mathMLtexVC );
$this->assertStringContainsString( ")", $mathMLtexVC );
$this->assertStringContainsString( "(", $mathMLtexVC );
}
public function testOver() {
$input = "{a \over b }";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "<mfrac>", $mathMLtexVC );
}
public function testBigcup() { public function testBigcup() {
$input = "\bigcup_{i=_1}^n E_i"; $input = "\bigcup_{i=_1}^n E_i";
$mathMLtexVC = $this->generateMML( $input ); $mathMLtexVC = $this->generateMML( $input );