mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-24 07:34:22 +00:00
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:
parent
b843a09e92
commit
89c9bb770e
|
@ -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 ) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue