mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 15:16:56 +00:00
Implement basic column info parsing
* For each letter l c or r that is found in the column spec the respective mtable alignment information is passed * if the align information is given externally the info will still be ignored Bug: T376838 Change-Id: I3113f933502df2109b066959e4d001736dbae6e6
This commit is contained in:
parent
9321d6ffc7
commit
602043027d
|
@ -525,11 +525,28 @@ class BaseParsing {
|
|||
$mtr = new MMLmtr();
|
||||
$mtd = new MMLmtd();
|
||||
$tableArgs = [ "columnspacing" => "1em", "rowspacing" => "4pt", 'rowlines' => '' ];
|
||||
$columnInfo = trim( $node->getColumnSpecs()->render(), "{} \n\r\t\v\x00" );
|
||||
if ( $align ) {
|
||||
$tableArgs['columnalign'] = $align;
|
||||
} elseif ( $columnInfo ) {
|
||||
$align = '';
|
||||
foreach ( str_split( $columnInfo ) as $chr ) {
|
||||
switch ( $chr ) {
|
||||
case 'r':
|
||||
$align .= 'right ';
|
||||
break;
|
||||
case 'l':
|
||||
$align .= 'left ';
|
||||
break;
|
||||
case 'c':
|
||||
$align .= 'center ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$tableArgs['columnalign'] = $align;
|
||||
}
|
||||
$mencloseArgs = [ 'notation' => '' ];
|
||||
$columnInfo = $node->getColumnSpecs()->render();
|
||||
|
||||
$lineNumber = 0;
|
||||
foreach ( $node as $row ) {
|
||||
$resInner .= $mtr->getStart();
|
||||
|
@ -576,6 +593,7 @@ class BaseParsing {
|
|||
// it seems this is creted when left and right is solely coming from columninfo
|
||||
$tableArgs = array_merge( $tableArgs, [ "columnlines" => "solid" ] );
|
||||
}
|
||||
|
||||
}
|
||||
$mtable = new MMLmtable( "", $tableArgs );
|
||||
if ( $cases || ( $open != null && $close != null ) ) {
|
||||
|
|
|
@ -165,4 +165,13 @@ class BaseParsingTest extends TestCase {
|
|||
$this->assertStringContainsString( 'top bottom', $result );
|
||||
}
|
||||
|
||||
public function testColumnSpecs() {
|
||||
$matrix = ( new TexVC() )->parse( '\\begin{array}{lcr}
|
||||
z & = & a \\\\
|
||||
f(x,y,z) & = & x + y + z
|
||||
\\end{array}' )[0];
|
||||
$result = BaseParsing::matrix( $matrix, [], null, 'matrix', '002A' );
|
||||
$this->assertStringContainsString( 'left center right ', $result );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue