Fix gcd, min, max statements

* with and without succeeding parentheses
* indices in FullCoverageTest: 21,22,33

Bug: T331998
Change-Id: I3a14db18764cc6df9b83249d19ed7de3b6489b1b
This commit is contained in:
Stegmujo 2023-03-14 15:57:30 +01:00
parent b843a09e92
commit 89c9bb770e
No known key found for this signature in database
GPG key ID: FEFA628F883FAE29
2 changed files with 21 additions and 6 deletions

View file

@ -519,16 +519,24 @@ class BaseParsing {
public static function namedOp( $node, $passedArgs, $operatorContent, $name, $id = null ) {
if ( !$id ) {
// $id = substr($name,1); eventually change how name is passed
$id = $name;
}
// This id statement probably wont work atm:
$args = count( $passedArgs ) >= 1 ? $passedArgs : [ "movablelimits" => "true" ];
// lim inf
$texClass = TexClass::OP;
if ( $name == "min" || $name == "max" || $name === "gcd" ) {
$args["form" ] = "prefix";
$texClass = "";
}
$id = str_replace( " ", ' ', $id );
$mo = new MMLmo( TexClass::OP, $args );
// "movesupsub"=>"true" activate this also as attribute ?
return $mo->encapsulateRaw( $id );
$mo = new MMLmo( $texClass, $args );
$ret = $mo->encapsulateRaw( $id );
if ( $operatorContent == "(" ) {
$moOp = new MMLmo( "", [ "stretchy" => "false" ] );
$ret .= $moOp->encapsulateRaw( "(" );
}
return $ret;
}
public static function over( $node, $passedArgs, $operatorContent, $name, $id = null ) {

View file

@ -10,6 +10,7 @@ use IntlChar;
class MMLutil {
/**
* Splits a regular expression in the form '\operatorname {someparams}
* Also recognizes succeeding parentheses '\operatorname (' as params
* @param string $input tex expression
* @return array|null found groups or null
*/
@ -17,6 +18,12 @@ class MMLutil {
$pattern = "/([\\a-zA-Z\s]+)\{([^}]+)\}/";
$matches = [];
$matched = preg_match_all( $pattern, $input, $matches );
if ( $matched ) {
return $matches;
}
$pattern2 = "/([\\a-zA-Z\s]+)(\()/";
$matches = [];
$matched = preg_match_all( $pattern2, $input, $matches );
return $matched ? $matches : null;
}