Merge "Use the same formatting for align as MathJax"

This commit is contained in:
jenkins-bot 2024-10-16 08:56:42 +00:00 committed by Gerrit Code Review
commit b236403991
3 changed files with 15 additions and 13 deletions

View file

@ -122,10 +122,7 @@ class BaseParsing {
$smth2 = null ) {
// Parsing is very similar to AmsEQArray, maybe extract function ... tcs: 178
$mrow = new MMLmrow();
// tbd how are the table args composed ?
$tableArgs = [ "columnalign" => "right",
"columnspacing" => "0em", "displaystyle" => "true", "rowspacing" => "3pt" ];
$mtable = new MMLmtable( "", $tableArgs );
$mtable = new MMLmtable( "" );
$mtr = new MMLmtr();
$mtd = new MMLmtd();
$renderedInner = "";
@ -141,14 +138,8 @@ class BaseParsing {
}
public static function amsEqnArray( $node, $passedArgs, $operatorContent, $name, $smth, $smth2 = null ) {
// this goes for name =="aligned" ... tcs: 358 420 421
$mrow = new MMLmrow();
// tbd how are the table args composed ?
$direction = ( $name == "aligned" ) ? "left" : "right";
$tableArgs = [ "columnalign" => $direction,
"columnspacing" => "0em", "displaystyle" => "true", "rowspacing" => "3pt" ];
$mtable = new MMLmtable( "", $tableArgs );
$mtable = new MMLmtable( '' );
$mtr = new MMLmtr();
$mtd = new MMLmtd();
$renderedInner = "";

View file

@ -12,7 +12,16 @@ use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\TexConstants\TexClass;
*/
class MMLmtable extends MMLbase {
public function __construct( string $texclass = TexClass::ORD, array $attributes = [] ) {
/** defaults to mtable args as generated from MathJax for align(ed) environment
*/
public function __construct(
string $texclass = TexClass::ORD,
array $attributes = [
'columnalign' => 'right left right left right left right left right left right left',
'columnspacing' => '0em 2em 0em 2em 0em 2em 0em 2em 0em 2em 0em',
'displaystyle' => 'true',
'rowspacing' => '3pt'
] ) {
parent::__construct( "mtable", $texclass, $attributes );
}
}

View file

@ -163,7 +163,9 @@ class MMLRenderTest extends MediaWikiUnitTestCase {
public function testAlignLeft() {
$input = " \begin{align} f(x) & = (a+b)^2 \\ & = a^2+2ab+b^2 \\ \\end{align} ";
$mathMLtexVC = $this->generateMML( $input );
$this->assertStringContainsString( "columnalign=\"left\"", $mathMLtexVC );
$this->assertStringContainsString( "columnalign=\"right left right", $mathMLtexVC );
$this->assertStringContainsString( "columnspacing=\"0em 2em 0em", $mathMLtexVC );
$this->assertStringContainsString( "rowspacing=\"3pt\"", $mathMLtexVC );
$this->assertStringContainsString( "mtable", $mathMLtexVC );
}