Remove mstyle around spacing elements

* From Feedback: There is a curious use of <mstyle> around spacing elements, as in <mstyle scriptlevel="0"><mspace width="-0.167em"></mspace></mstyle>. I am not sure that wrapper element is needed? The mspace ought to be successful standalone.
* this is in the 'bmod' case

Bug: T349822
Change-Id: I9229ad73891d5000679761d3d4b2028d4a51ddf1
This commit is contained in:
Stegmujo 2023-10-11 09:20:34 +00:00
parent 06038f8bae
commit 8112c65a5d
No known key found for this signature in database
GPG key ID: BB616B7CC84186BE
2 changed files with 8 additions and 6 deletions

View file

@ -486,12 +486,11 @@ class BaseParsing {
case "bmod":
$mo = new MMLmo( "", [ "lspace" => Sizes::THICKMATHSPACE, "rspace" => Sizes::THICKMATHSPACE ] );
$mmlRow = new MMLmrow( TexClass::ORD );
$mstyle = new MMLmstyle( "", [ "scriptlevel" => "0" ] );
$mspace = new MMLmspace( "", [ "width" => "0.167em" ] );
$inner = $node->getArg() instanceof TexNode ?
$mmlRow->encapsulateRaw( $node->getArg()->renderMML() ) : "";
return $mmlRow->encapsulateRaw( $mo->encapsulate( "mod" ) .
$inner . $mmlRow->encapsulateRaw( $mstyle->encapsulateRaw( $mspace->getEmpty() ) ) );
$inner . $mmlRow->encapsulateRaw( $mspace->getEmpty() ) );
case "implies":
$mstyle = new MMLmstyle( "", [ "scriptlevel" => "0" ] );
$mspace = new MMLmspace( "", [ "width" => "0.278em" ] );
@ -1018,11 +1017,9 @@ class BaseParsing {
}
public static function spacer( $node, $passedArgs, $operatorContent, $name, $withIn = null, $smth2 = null ) {
// var node = parser.create('node', 'mspace', [], { width: (0, lengths_js_1.em)(space) });
$mstyle = new MMLmstyle( "", [ "scriptlevel" => "0" ] );
$width = MMLutil::round2em( $withIn );
$mspace = new MMLmspace( "", [ "width" => $width ] );
return $mstyle->encapsulateRaw( $mspace->encapsulate() );
return $mspace->encapsulate();
}
public static function smash( $node, $passedArgs, $operatorContent, $name ) {

View file

@ -14,6 +14,12 @@ use MediaWikiUnitTestCase;
* @covers \MediaWiki\Extension\Math\TexVC\TexVC
*/
class MMLRenderTest extends MediaWikiUnitTestCase {
public function testSpacesNoMstyle() {
$input = "\bmod \, \!";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "mspace", $mathMLtexVC );
$this->assertStringNotContainsString( "mstyle", $mathMLtexVC );
}
public function testAlignLeft() {
$input = " \begin{align} f(x) & = (a+b)^2 \\ & = a^2+2ab+b^2 \\ \\end{align} ";
@ -182,7 +188,6 @@ class MMLRenderTest extends MediaWikiUnitTestCase {
public function testRenderSpaceSemicolon() {
$input = "{\\;}";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "mstyle", $mathMLtexVC );
$this->assertStringContainsString( "mspace", $mathMLtexVC, );
}