mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-27 17:01:07 +00:00
Simplify parsing of mediawiki_function_names
Just convert mediawiki_function_names to the respective \operatorname construct. Bug: T375274 Change-Id: Ie374524dbdf6a753063172fb88e6f60e91b9212e
This commit is contained in:
parent
db81c96062
commit
c9f7d9131f
File diff suppressed because it is too large
Load diff
|
@ -137,6 +137,16 @@ lit
|
|||
$this->line(), $this->column());
|
||||
}
|
||||
}
|
||||
/ f:generic_func &{ return $this->tu->mediawiki_function_names($f); } _
|
||||
{
|
||||
if(is_array($f)) {
|
||||
// This is an unexpected case, but covers the ambiguity of slice in javascript.
|
||||
$fProcessed = implode(array_slice($f, 1));
|
||||
} else {
|
||||
$fProcessed = substr($f,1);
|
||||
}
|
||||
return new Fun1nb( '\\operatorname', new Literal( $fProcessed ) );
|
||||
}
|
||||
/ r:DELIMITER { return new Literal($r); }
|
||||
/ b:BIG r:DELIMITER { return new Big($b, $r); }
|
||||
/ b:BIG SQ_CLOSE { return new Big($b, "]"); }
|
||||
|
@ -144,7 +154,7 @@ lit
|
|||
/ name:FUN_AR1opt e:expr_nosqc SQ_CLOSE l:lit /* must be before FUN_AR1 */
|
||||
{ return new Fun2sq($name, $e->setCurly(), $l); }
|
||||
/ name:FUN_AR1 l:lit { return new Fun1($name, $l); }
|
||||
/ name:FUN_AR1nb l:lit {return new Fun1nb($name, $l); }
|
||||
/ name:FUN_AR1nb l:lit { return new Fun1nb($name, $l); }
|
||||
/ name:FUN_MHCHEM l:chem_lit { return new Mhchem($name, $l); }
|
||||
/ name:FUN_AR2 l1:lit l2:lit { return new Fun2($name, $l1, $l2); }
|
||||
/ name:FUN_AR4_MHCHEM_TEXIFIED l1:lit l2:lit l3:lit l4:lit { return new Fun4($name, $l1, $l2, $l3, $l4); }
|
||||
|
@ -317,17 +327,6 @@ BOX
|
|||
LITERAL
|
||||
= c:( literal_id / literal_mn / literal_uf_lt / "-" / literal_uf_op ) _
|
||||
{ return $c; }
|
||||
/ f:generic_func &{ return $this->tu->mediawiki_function_names($f); } _
|
||||
c:( "(" / "[" / "\\{" / "" { return " ";}) _
|
||||
{
|
||||
if(is_array($f)) {
|
||||
// This is an unexpected case, but covers the ambiguity of slice in javascript.
|
||||
$fProcessed = implode(array_slice($f, 1));
|
||||
} else {
|
||||
$fProcessed = substr($f,1);
|
||||
}
|
||||
return "\\operatorname {" . $fProcessed . "}" . $c;
|
||||
}
|
||||
/ f:generic_func &{ return $this->tu->nullary_macro($f); } _ // from Texutil.find(...)
|
||||
{ return $f . " "; }
|
||||
/ f:generic_func &{ return $this->options['usemathrm'] && $this->tu->nullary_macro_in_mbox($f); } _ // from Texutil.find(...)
|
||||
|
|
|
@ -69,13 +69,20 @@ class AllTest extends MediaWikiUnitTestCase {
|
|||
],
|
||||
'MediaWiki functions' => [
|
||||
[
|
||||
'input' => '\\arccot\\arcsec\\arccsc\\sgn\\sen',
|
||||
'input' => '\\arccot \\arcsec \\arccsc \\sgn \\sen ',
|
||||
'output' =>
|
||||
'\\operatorname {arccot} \\operatorname {arcsec} ' .
|
||||
'\\operatorname {arccsc} \\operatorname {sgn} ' .
|
||||
'\\operatorname {sen} '
|
||||
]
|
||||
],
|
||||
'MediaWiki functions args' => [
|
||||
[
|
||||
'input' => '\\arccot(x)\\sen(x)\\sen{x}',
|
||||
'output' =>
|
||||
'\\operatorname {arccot} (x)\\operatorname {sen} (x)\\operatorname {sen} {x}'
|
||||
]
|
||||
],
|
||||
'Literals (1)' => [
|
||||
[
|
||||
'input' =>
|
||||
|
|
Loading…
Reference in a new issue