Fix bigcap and bigcup scripts not placed correctly

* All recognized macros are in category nullary macros, so this adds a
  rule
* In test "\bigcap_{i=_1}^n E_i"
* In test "\bigcup_{i=_1}^n E_i"

Bug: T315978
Change-Id: I09287879c1448e404473891985457349a62554a7
This commit is contained in:
Stegmujo 2023-09-27 11:32:33 +00:00
parent 4d3f6adc8f
commit 093ecf7c0f
No known key found for this signature in database
GPG key ID: BB616B7CC84186BE
2 changed files with 16 additions and 1 deletions

View file

@ -9,6 +9,7 @@ use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmrow;
use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmstyle; use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmstyle;
use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmsubsup; use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmsubsup;
use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmunderover; use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmunderover;
use MediaWiki\Extension\Math\TexVC\TexUtil;
class FQ extends TexNode { class FQ extends TexNode {
@ -73,7 +74,10 @@ class FQ extends TexNode {
// tbd check for more such cases like TexUtilTest 317 // tbd check for more such cases like TexUtilTest 317
$base = $this->getBase(); $base = $this->getBase();
if ( $base instanceof Literal ) { if ( $base instanceof Literal ) {
if ( trim( $this->getBase()->getArgs()[0] ) === "\\sum" ) { $litArg = trim( $this->getBase()->getArgs()[0] );
$tu = TexUtil::getInstance();
// "sum", "bigcap", "bigcup", "prod" ... all are nullary macros.
if ( $tu->nullary_macro( $litArg ) ) {
$melement = new MMLmunderover(); $melement = new MMLmunderover();
} }
} }

View file

@ -14,6 +14,17 @@ use MediaWikiUnitTestCase;
* @covers \MediaWiki\Extension\Math\TexVC\TexVC * @covers \MediaWiki\Extension\Math\TexVC\TexVC
*/ */
class MMLRenderTest extends MediaWikiUnitTestCase { class MMLRenderTest extends MediaWikiUnitTestCase {
public function testBigcup() {
$input = "\bigcup_{i=_1}^n E_i";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "munderover", $mathMLtexVC );
}
public function testBigcap() {
$input = "\bigcap_{i=_1}^n E_i";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "munderover", $mathMLtexVC );
}
public function testNotOperatorname() { public function testNotOperatorname() {
$input = "\\not\operatorname{R}"; $input = "\\not\operatorname{R}";