Pass font options in accents

Accents such as \widetilde did not pass
their font options to their child element.

* Pass options
* Add test
* In I6924d712db6852f99d7896b1f11cfbd22851d757
  curly learned to encapsulate its output in a
  mrow. Thus, the if-clause is no longer needed.

Bug: T352609
Change-Id: I81ecda09d017c73a4593ae36c630426229c7559f
This commit is contained in:
Moritz Schubotz (physikerwelt) 2024-01-27 18:12:03 +01:00
parent 722bb0f778
commit d270a9aa80
No known key found for this signature in database
GPG key ID: F803DB146DDF36C3
2 changed files with 34 additions and 9 deletions

View file

@ -71,21 +71,13 @@ class BaseParsing {
$entity = $accent; $entity = $accent;
} }
if ( $node->getArg() instanceof Curly && $node->getArg()->getArg() instanceof TexArray
&& count( $node->getArg()->getArg()->getArgs() ) > 1 ) {
$mrow = new MMLmrow();
$renderedArg = $mrow->encapsulateRaw( $node->getArg()->renderMML() );
} else {
$renderedArg = $node->getArg()->renderMML();
}
$mrow = new MMLmrow(); $mrow = new MMLmrow();
$mo = new MMLmo( "", $attrs ); // $passedArgs $mo = new MMLmo( "", $attrs ); // $passedArgs
$mover = new MMLmover(); $mover = new MMLmover();
$ret = $mrow->encapsulateRaw( $ret = $mrow->encapsulateRaw(
$mrow->encapsulateRaw( $mrow->encapsulateRaw(
$mover->encapsulateRaw( $mover->encapsulateRaw(
$renderedArg . $node->getArg()->renderMML( $passedArgs ) .
$mo->encapsulateRaw( $entity ) $mo->encapsulateRaw( $entity )
) )
) )

View file

@ -0,0 +1,33 @@
<?php
namespace MediaWiki\Extension\Math\Tests\WikiTexVC\MMLmappings;
use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseParsing;
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Fun1;
use MediaWiki\Extension\Math\WikiTexVC\Nodes\Literal;
use PHPUnit\Framework\TestCase;
/**
* @covers \MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseParsing
*/
class BaseParsingTest extends TestCase {
public function testAccent() {
$node = new Fun1(
'\\widetilde',
( new Literal( 'a' ) )
);
$result = BaseParsing::accent( $node, [], null, 'widetilde', '007E' );
$this->assertStringContainsString( '~', $result );
$this->assertStringContainsString( 'mover', $result );
}
public function testAccentArgPassing() {
$node = new Fun1(
'\\widetilde',
( new Literal( 'a' ) )
);
$result = BaseParsing::accent( $node, [ 'k' => 'v' ], null, 'widetilde', '007E' );
$this->assertStringContainsString( '<mi k="v"', $result );
}
}