Файловый менеджер - Редактировать - /var/www/html/Nodes.zip
Ðазад
PK ! ��ʷ� � Fun1nb.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Fun1nb extends Fun1 { /** @inheritDoc */ public function inCurlies() { return '{' . $this->render() . '}'; } /** @inheritDoc */ public function render() { return $this->fname . ' ' . $this->arg->inCurlies() . ' '; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ): string { return $this->parseToMML( $this->fname, $arguments, $state ); } } PK ! h⼠� � Fun4.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Fun4 extends TexNode { /** @var string */ protected $fname; /** @var TexNode */ protected $arg1; /** @var TexNode */ protected $arg2; /** @var TexNode */ protected $arg3; /** @var TexNode */ protected $arg4; public function __construct( string $fname, TexNode $arg1, TexNode $arg2, TexNode $arg3, TexNode $arg4 ) { parent::__construct( $fname, $arg1, $arg2, $arg3, $arg4 ); $this->fname = $fname; $this->arg1 = $arg1; $this->arg2 = $arg2; $this->arg3 = $arg3; $this->arg4 = $arg4; } /** * @return string */ public function getFname(): string { return $this->fname; } /** * @return TexNode */ public function getArg1(): TexNode { return $this->arg1; } /** * @return TexNode */ public function getArg2(): TexNode { return $this->arg2; } /** * @return TexNode */ public function getArg3(): TexNode { return $this->arg3; } /** * @return TexNode */ public function getArg4(): TexNode { return $this->arg4; } /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { return '{' . $this->fname . ' ' . $this->arg1->inCurlies() . $this->arg2->inCurlies() . $this->arg3->inCurlies() . $this->arg4->inCurlies() . '}'; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ): string { return $this->parseToMML( $this->fname, $arguments, $state ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { if ( $args == null ) { $args = [ $this->arg1, $this->arg2, $this->arg3, $this->arg4 ]; } return parent::extractIdentifiers( $args ); } } PK ! n��� � ChemWord.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmtext; class ChemWord extends TexNode { /** @var TexNode */ public $left; /** @var TexNode */ public $right; public function __construct( TexNode $left, TexNode $right ) { parent::__construct( $left, $right ); $this->left = $left; $this->right = $right; } /** * @return TexNode */ public function getLeft(): TexNode { return $this->left; } /** * @return TexNode */ public function getRight(): TexNode { return $this->right; } /** @inheritDoc */ public function render() { return $this->left->render() . $this->right->render(); } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { $mmlMrow = new MMLmrow(); $mtextLeft = new MMLmtext( "", [ "mathcolor" => "red" ] ); $mtextRight = new MMLmtext(); // If right has empty literal content is resolved as dash $right = $this->getRight()->getArgs()[0] == "" ? "-" : $this->getRight()->renderMML( [], $state ); return $mmlMrow->encapsulateRaw( $mmlMrow->encapsulateRaw( $mtextLeft->encapsulateRaw( $this->getLeft()->renderMML( [], $state ) ) . $mtextRight->encapsulateRaw( $right ) ) ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { return []; } } PK ! "!��_ _ Fun2sq.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Fun2sq extends Fun2 { /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { return '{' . $this->fname . '[' . $this->arg1->render() . ']' . $this->arg2->inCurlies() . '}'; } } PK ! ��� � Literal.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseMethods; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLParsingUtil; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLutil; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmi; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmn; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmo; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmpadded; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmstyle; use MediaWiki\Extension\Math\WikiTexVC\TexUtil; class Literal extends TexNode { /** @var string */ private $arg; /** @var string[] */ private $literals; /** @var string[] */ private $extendedLiterals; public function __construct( string $arg ) { parent::__construct( $arg ); $this->arg = $arg; $this->literals = array_keys( TexUtil::getInstance()->getBaseElements()['is_literal'] ); $this->extendedLiterals = $this->literals; array_push( $this->extendedLiterals, '\\infty', '\\emptyset' ); } public function changeUnicodeFontInput( string $input, array &$state ): string { /** * In some font modifications, it is required to explicitly use Unicode * characters instead of (only) attributes in MathML to indicate the font. * This is mostly because of Chrome behaviour. See: https://phabricator.wikimedia.org/T352196 */ if ( isset( $state["double-struck-literals"] ) ) { return MMLParsingUtil::mapToDoubleStruckUnicode( $input ); } elseif ( isset( $state["calligraphic"] ) ) { return MMLParsingUtil::mapToCaligraphicUnicode( $input ); } elseif ( isset( $state["fraktur"] ) ) { return MMLParsingUtil::mapToFrakturUnicode( $input ); } elseif ( isset( $state["bold"] ) ) { return MMLParsingUtil::mapToBoldUnicode( $input ); } return $input; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { if ( isset( $state["intent-params"] ) ) { foreach ( $state["intent-params"] as $intparam ) { if ( $intparam == $this->arg ) { $arguments["arg"] = $intparam; } } } if ( isset( $state["intent-params-expl"] ) ) { $arguments["arg"] = $state["intent-params-expl"]; } if ( $this->arg === " " ) { // Fixes https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/961711 // And they creation of empty mo elements. return ""; } if ( is_numeric( $this->arg ) ) { $mn = new MMLmn( "", $arguments ); return $mn->encapsulateRaw( $this->changeUnicodeFontInput( $this->arg, $state ) ); } // is important to split and find chars within curly and differentiate, see tc 459 $foundOperatorContent = MMLutil::initalParseLiteralExpression( $this->arg ); if ( !$foundOperatorContent ) { $input = $this->arg; $operatorContent = null; } else { $input = $foundOperatorContent[1][0]; $operatorContent = [ "foundOC" => $foundOperatorContent[2][0] ]; } // This is rather a workaround: // Sometimes literals from WikiTexVC contain complete \\operatorname {asd} hinted as bug tex-2-mml.json if ( str_contains( $input, "\\operatorname" ) ) { $mi = new MMLmi(); return $mi->encapsulateRaw( $operatorContent["foundOC"] ); } $inputP = $input; // Sieve for Operators $bm = new BaseMethods(); $noStretchArgs = $arguments; // Delimiters and operators should not be stretchy by default when used as literals $noStretchArgs['stretchy'] ??= 'false'; $ret = $bm->checkAndParseOperator( $inputP, $this, $noStretchArgs, $operatorContent, $state, false ); if ( $ret ) { return $ret; } // Sieve for mathchar07 chars $bm = new BaseMethods(); $ret = $bm->checkAndParseMathCharacter( $inputP, $this, $arguments, $operatorContent, false ); if ( $ret ) { return $ret; } // Sieve for Identifiers $ret = $bm->checkAndParseIdentifier( $inputP, $this, $arguments, $operatorContent, false ); if ( $ret ) { return $ret; } // Sieve for Delimiters $ret = $bm->checkAndParseDelimiter( $input, $this, $noStretchArgs, $operatorContent ); if ( $ret ) { return $ret; } // Sieve for Makros $ret = BaseMethods::checkAndParse( $inputP, $arguments, array_merge( $operatorContent ?? [], $state ?? [] ), $this, false ); if ( $ret || $ret === '' ) { return $ret; } // Specific if ( !( empty( $state['inMatrix'] ) ) && trim( $this->arg ) === '\vline' ) { return $this->createVlineElement(); } if ( !( empty( $state['inHBox'] ) ) ) { // No mi, if literal is from HBox return $input; } // If falling through all sieves just create an MI element $mi = new MMLmi( "", $arguments ); return $mi->encapsulateRaw( $this->changeUnicodeFontInput( $input, $state ) ); // $this->arg } /** * @return string */ public function getArg(): string { return $this->arg; } public function setArg( string $arg ) { $this->arg = $arg; } /** * @return int[]|string[] */ public function getLiterals(): array { return $this->literals; } /** * @return int[]|string[] */ public function getExtendedLiterals(): array { return $this->extendedLiterals; } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { return $this->getLiteral( $this->literals, '/^([a-zA-Z\']|\\\\int)$/' ); } /** @inheritDoc */ public function extractSubscripts() { return $this->getLiteral( $this->extendedLiterals, '/^([0-9a-zA-Z+\',-])$/' ); } /** @inheritDoc */ public function getModIdent() { if ( $this->arg === '\\ ' ) { return [ '\\ ' ]; } return $this->getLiteral( $this->literals, '/^([0-9a-zA-Z\'])$/' ); } private function getLiteral( array $lit, string $regexp ): array { $s = trim( $this->arg ); if ( preg_match( $regexp, $s ) == 1 ) { return [ $s ]; } elseif ( in_array( $s, $lit, true ) ) { return [ $s ]; } else { return []; } } /** * @return string */ public function createVlineElement(): string { $mrow = new MMLmrow(); $mpAdded = new MMLmpadded( "", [ "depth" => "0", "height" => "0" ] ); $mStyle = new MMLmstyle( "", [ "mathsize" => "1.2em" ] ); $mo = new MMLmo( "", [ "fence" => "false", "stretchy" => "false" ] ); return $mrow->encapsulateRaw( $mpAdded->encapsulateRaw( $mStyle->encapsulateRaw( $mo->encapsulateRaw( "|" ) ) ) ); } } PK ! F�V0 0 Mhchem.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Mhchem extends Fun1 { /** @inheritDoc */ public function inCurlies() { return '{' . $this->render() . '}'; } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { return []; } } PK ! g�+S Matrix.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use Generator; use InvalidArgumentException; class Matrix extends TexArray { /** @var string */ private $top; private array $lines = []; private ?TexArray $columnSpecs = null; private ?string $renderedColumSpecs = null; private ?array $boarder = null; private ?string $alignInfo = null; public function __construct( string $top, TexArray $mainarg, ?LengthSpec $rowSpec = null ) { foreach ( $mainarg->args as $row ) { if ( !$row instanceof TexArray ) { throw new InvalidArgumentException( 'Nested arguments have to be type of TexArray' ); } $this->lines[] = $row->containsFunc( '\hline' ); } if ( $mainarg instanceof Matrix ) { $this->args = $mainarg->args; $this->curly = $mainarg->curly; } else { parent::__construct( ...$mainarg->args ); } $this->top = $top; if ( $rowSpec && count( $this->args ) ) { // @phan-suppress-next-line PhanUndeclaredMethod $this->first()->setRowSpecs( $rowSpec ); } } public function getLines(): array { return $this->lines; } /** * @return string */ public function getTop(): string { return $this->top; } public function setTop( string $top ): Matrix { $this->top = $top; return $this; } public function getRenderedColumnSpecs(): string { if ( $this->renderedColumSpecs == null ) { $this->renderColumnSpecs(); } return $this->renderedColumSpecs; } public function setColumnSpecs( TexArray $specs ): Matrix { $this->columnSpecs = $specs; $this->renderedColumSpecs = null; $this->alignInfo = null; $this->boarder = null; return $this; } public function hasColumnInfo(): bool { return $this->getRenderedColumnSpecs() !== ''; } public function getAlignInfo(): string { if ( $this->alignInfo == null ) { $this->renderColumnSpecs(); } return $this->alignInfo; } /** * @return TexArray */ public function getMainarg(): TexArray { return $this; } /** @inheritDoc */ public function containsFunc( $target, $args = null ) { if ( $args == null ) { $args = [ '\\begin{' . $this->top . '}', '\\end{' . $this->top . '}', ...$this->args, ]; } return parent::containsFunc( $target, $args ); } /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { $colSpecs = $this->columnSpecs !== null ? $this->columnSpecs->render() : ''; return '{\\begin{' . $this->top . '}' . $colSpecs . $this->renderMatrix( $this ) . '\\end{' . $this->top . '}}'; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ): string { return $this->parseToMML( $this->getTop(), $arguments, null ); } private function renderMatrix( Matrix $matrix ): string { $renderedLines = ''; for ( $i = 0; $i < count( $matrix->args ); $i++ ) { $renderedLines .= self::renderLine( $matrix->args[$i] ); if ( $i < count( $matrix->args ) - 1 ) { // @phan-suppress-next-line PhanTypeMismatchArgumentSuperType $renderedLines .= $matrix->renderRowSpec( $matrix->args[$i] ); } } return $renderedLines; } private static function renderLine( TexNode $l ): string { $mapped = array_map( static function ( $x ){ return $x->render(); }, $l->args ); return implode( '&', $mapped ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { if ( $args == null ) { $args = $this->args; } $mapped = array_map( function ( $a ){ return array_map( function ( $p ){ return parent::extractIdentifiers( $p->args ); }, $a->args ); }, $args ); return self::flatDeep( $mapped ); } /** * @param array|string $a * @return array|string */ private static function flatDeep( $a ) { if ( !is_array( $a ) ) { return $a; } $reduced = array_reduce( $a, [ self::class, 'reduceCallback' ], [] ); return $reduced; } /** * @param array $acc * @param array|string $val * @return array */ private static function reduceCallback( $acc, $val ) { // Casting to array if output is string, this is required for array_merge function. $fld = self::flatDeep( $val ); if ( !is_array( $fld ) ) { $fld = [ $fld ]; } return array_merge( $acc, $fld ); } /** * @suppress PhanTypeMismatchReturn * @return Generator<TexArray> */ public function getIterator(): Generator { return parent::getIterator(); } /** * @return void */ public function renderColumnSpecs(): void { $colSpecs = $this->columnSpecs ?? new TexArray(); $this->renderedColumSpecs = trim( $colSpecs->render(), "{} \n\r\t\v\x00" ); $align = ''; $colNo = 0; $this->boarder = []; foreach ( str_split( $this->renderedColumSpecs ) as $chr ) { switch ( $chr ) { case '|': $this->boarder[$colNo] = true; break; case 'r': $align .= 'right '; $colNo++; break; case 'l': $align .= 'left '; $colNo++; break; case 'c': $colNo++; $align .= 'center '; break; } } $this->alignInfo = $align; } public function getBoarder(): array { if ( $this->boarder == null ) { $this->renderColumnSpecs(); } return $this->boarder; } public function renderRowSpec( TexArray $row ): string { $rowSpecs = ''; if ( $row->getRowSpecs() !== null ) { $rowSpecs = $row->getRowSpecs()->render(); } return '\\\\' . $rowSpecs; } } PK ! �[�Z\ \ Fun2nb.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Fun2nb extends Fun2 { /** @inheritDoc */ public function inCurlies() { return '{' . $this->render() . '}'; } /** @inheritDoc */ public function render() { return $this->fname . ' ' . $this->arg1->inCurlies() . $this->arg2->inCurlies(); } } PK ! ��l� FQ.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseParsing; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmstyle; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmsubsup; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmunderover; use MediaWiki\Extension\Math\WikiTexVC\TexUtil; class FQ extends TexNode { /** @var TexNode */ private $base; /** @var TexNode */ private $up; /** @var TexNode */ private $down; public function __construct( TexNode $base, TexNode $down, TexNode $up ) { parent::__construct( $base, $down, $up ); $this->base = $base; $this->up = $up; $this->down = $down; } /** * @return TexNode */ public function getBase(): TexNode { return $this->base; } /** * @return TexNode */ public function getUp(): TexNode { return $this->up; } /** * @return TexNode */ public function getDown(): TexNode { return $this->down; } /** @inheritDoc */ public function render() { return $this->base->render() . '_' . $this->down->inCurlies() . '^' . $this->up->inCurlies(); } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { if ( array_key_exists( "limits", $state ) ) { // A specific FQ case with preceding limits, just invoke the limits parsing manually. return BaseParsing::limits( $this, $arguments, $state, "" ); } $base = $this->getBase(); if ( $base->getLength() == 0 && !$base->isCurly() ) { // this happens when FQ is located in Sideset (is this a common parsing way?) $mrow = new MMLmrow(); return $mrow->encapsulateRaw( $this->getDown()->renderMML( [], $state ) ) . $mrow->encapsulateRaw( $this->getUp()->renderMML( [], $state ) ); } $melement = new MMLmsubsup(); // tbd check for more such cases like TexUtilTest 317 if ( $base instanceof Literal ) { $litArg = trim( $base->getArgs()[0] ); $tu = TexUtil::getInstance(); // "sum", "bigcap", "bigcup", "prod" ... all are nullary macros. if ( $tu->nullary_macro( $litArg ) && !$tu->is_literal( $litArg ) && // by default (inline-displaystyle large operators should be used) ( $state['styleargs']['displaystyle'] ?? 'true' ) === 'true' ) { $melement = new MMLmunderover(); } } $mrow = new MMLmrow(); $emptyMrow = ""; // In cases with empty curly preceding like: "{}_1^2\!\Omega_3^4" if ( $base->isCurly() && $base->isEmpty() ) { $emptyMrow = $mrow->getEmpty(); } // This seems to be the common case $inner = $melement->encapsulateRaw( $emptyMrow . $base->renderMML( [], $state ) . $mrow->encapsulateRaw( $this->getDown()->renderMML( $arguments, $state ) ) . $mrow->encapsulateRaw( $this->getUp()->renderMML( $arguments, $state ) ) ); if ( $melement instanceof MMLmunderover ) { $args = $state['styleargs'] ?? [ "displaystyle" => "true", "scriptlevel" => 0 ]; $style = new MMLmstyle( "", $args ); return $style->encapsulateRaw( $inner ); } return $inner; } } PK ! S�� Fun2.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Fun2 extends TexNode { /** @var string */ protected $fname; /** @var TexNode */ protected $arg1; /** @var TexNode */ protected $arg2; public function __construct( string $fname, TexNode $arg1, TexNode $arg2 ) { parent::__construct( $fname, $arg1, $arg2 ); $this->fname = $fname; $this->arg1 = $arg1; $this->arg2 = $arg2; } /** * @return string */ public function getFname(): string { return $this->fname; } /** * @return TexNode */ public function getArg1(): TexNode { return $this->arg1; } /** * @return TexNode */ public function getArg2(): TexNode { return $this->arg2; } /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { return '{' . $this->fname . ' ' . $this->arg1->inCurlies() . $this->arg2->inCurlies() . '}'; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ): string { return $this->parseToMML( $this->fname, $arguments, $state ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { if ( $args == null ) { $args = [ $this->arg1, $this->arg2 ]; } return parent::extractIdentifiers( $args ); } } PK ! ��» � ChemFun2u.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class ChemFun2u extends TexNode { /** @var string */ private $fname; /** @var TexNode */ private $left; /** @var TexNode */ private $right; /** * @return string */ public function getFname(): string { return $this->fname; } public function __construct( string $fname, TexNode $left, TexNode $right ) { parent::__construct( $fname, $left, $right ); $this->fname = $fname; $this->left = $left; $this->right = $right; } /** * @return TexNode */ public function getLeft(): TexNode { return $this->left; } /** * @return TexNode */ public function getRight(): TexNode { return $this->right; } /** @inheritDoc */ public function render() { return $this->fname . $this->left->inCurlies() . '_' . $this->right->inCurlies(); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { return []; } } PK ! ܟe LengthSpec.phpnu �Iw�� <?php namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use InvalidArgumentException; class LengthSpec extends TexNode { private string $sign; private string $unit; private string $number; public function __construct( ?string $sign, array $number, string $unit ) { $this->sign = $sign ?? ''; $this->unit = $unit; if ( count( $number ) === 3 ) { $this->number = implode( $number[0] ) . ( $number[1] ?? '' ) . implode( $number[2] ); } elseif ( count( $number ) === 2 ) { $this->number = ( $number[0] ?? '' ) . implode( $number[1] ); } else { throw new InvalidArgumentException( 'Invalid number in length spec' ); } parent::__construct(); } /** @inheritDoc */ public function render() { return '[' . $this->sign . $this->number . $this->unit . ']'; } } PK ! B&��9? 9? TexArray.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use Generator; use InvalidArgumentException; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLParsingUtil; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util\MMLutil; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmo; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmstyle; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmsup; use MediaWiki\Extension\Math\WikiTexVC\TexUtil; /** * */ class TexArray extends TexNode implements \ArrayAccess, \IteratorAggregate { protected bool $curly = false; private ?LengthSpec $rowSpecs = null; /** * @param TexNode|string ...$args * @return self */ public static function newCurly( ...$args ) { $node = new self( ...$args ); $node->curly = true; return $node; } /** @inheritDoc */ public function __construct( ...$args ) { $nargs = []; foreach ( $args as &$arg ) { if ( $arg !== null ) { array_push( $nargs, $arg ); } } self::checkInput( $nargs ); parent::__construct( ...$nargs ); } public function checkForStyleArgs( TexNode $node ): ?array { if ( $node instanceof Literal ) { $name = trim( $node->getArg() ); switch ( $name ) { case "\\displaystyle": return [ "displaystyle" => "true", "scriptlevel" => "0" ]; case "\\scriptstyle": return [ "displaystyle" => "false", "scriptlevel" => "1" ]; case "\\scriptscriptstyle": return [ "displaystyle" => "false", "scriptlevel" => "2" ]; case "\\textstyle": return [ "displaystyle" => "false", "scriptlevel" => "0" ]; } } return null; } /** * Checks if an TexNode of Literal contains color information (color, pagecolor) * and returns info how to continue with the parsing. * @param TexNode $node node to check if it contains color info * @return array index 0: (bool) was color element found, index 1: (string) specified color */ public function checkForColor( TexNode $node ) { if ( $node instanceof Literal ) { $name = trim( $node->getArg() ); if ( str_contains( $name, "\\color" ) ) { $foundOperatorContent = MMLutil::initalParseLiteralExpression( $node->getArg() ); if ( !$foundOperatorContent ) { // discarding color elements which not specify color return [ true, null ]; } else { return [ true, $foundOperatorContent[2][0] ]; } } elseif ( str_contains( $name, "\\pagecolor" ) ) { return [ true, null ]; } } return [ false, null ]; } public function checkForColorDefinition( TexNode $node ): ?array { if ( $node instanceof Literal ) { $name = trim( $node->getArg() ); if ( str_contains( $name, "\\definecolor" ) ) { return MMLParsingUtil::parseDefineColorExpression( $node->getArg() ); } } return null; } /** * Checks two sequential nodes in TexArray if they contain information on sideset expressions. * @param TexNode $currentNode first node in array to check (for sideset expression) * @param TexNode|null $nextNode second node in array to check (for succeeding operator) * @return TexNode|null the succeeding operator for further Parsing or null if sideset not found or invalid */ public function checkForSideset( TexNode $currentNode, ?TexNode $nextNode ): ?TexNode { if ( !( $currentNode instanceof Fun2nb && $currentNode->getFname() == "\\sideset" ) ) { return null; } if ( $nextNode instanceof Literal || $nextNode instanceof DQ || $nextNode instanceof UQ || $nextNode instanceof FQ ) { return $nextNode; } return null; } public function checkForLimits( TexNode $currentNode, ?TexNode $nextNode ): array { // Preceding 'lim' in example: "\\lim_{x \\to 2}" if ( ( $currentNode instanceof DQ || $currentNode instanceof FQ ) && $currentNode->containsFunc( "\\lim" ) ) { if ( $currentNode->getBase() instanceof TexArray ) { return [ $currentNode->getBase()->getArgs()[0], false ]; } else { return [ $currentNode->getBase(), false ]; } } /** Find cases which have preceding Literals with nullary_macro-type operators i.e.: * "\iint\limits_D \, dx\,dy" */ $tu = TexUtil::getInstance(); // Check whether the current node is a possible preceding literal if ( !( // logically superfluous brackets were inserted to improve readability ( $currentNode instanceof Literal && // Check if the current node is a nullary macro such as \iint, \sum, \prod, etc. ( $tu->nullary_macro( trim( $currentNode->getArg() ) ) // or a limit operator || ( trim( $currentNode->getArg() ) == "\\lim" ) ) ) || // or the special case of \operatorname ( $currentNode instanceof Fun1nb && $currentNode->getFname() == "\\operatorname" ) ) ) { return [ null, false ]; } // Check whether the next node is a possible limits construct if ( !( ( $nextNode instanceof DQ || $nextNode instanceof FQ ) && $nextNode->getBase() instanceof Literal && ( $nextNode->containsFunc( "\\limits" ) || $nextNode->containsFunc( "\\nolimits" ) ) ) ) { return [ null, false ]; } return [ $currentNode, true ]; } public function checkForNot( TexNode $currentNode ): bool { if ( $currentNode instanceof Literal && trim( $currentNode->getArg() ) == "\\not" ) { return true; } return false; } public function checkForDerivatives( int $iStart, array $args ): int { $ctr = 0; for ( $i = $iStart, $count = count( $this->args ); $i < $count; $i++ ) { $followUp = $args[$i]; if ( $followUp instanceof Literal && $followUp->getArg() === "'" ) { $ctr++; } else { break; } } return $ctr; } public function checkForNamedFctArgs( TexNode $currentNode, ?TexNode $nextNode ): array { // Check if current node is named function $hasNamedFct = false; if ( $currentNode instanceof TexArray && count( $currentNode->args ) == 2 ) { $tu = TexUtil::getInstance(); $currentNodeContent = $currentNode[0]; if ( $currentNodeContent instanceof Literal && $tu->latex_function_names( $currentNodeContent->getArg() ) ) { $hasNamedFct = true; } } elseif ( $currentNode instanceof Fun1nb && $currentNode->getFname() === '\\operatorname' ) { $hasNamedFct = true; } // Check if there is a valid argument as next parameter $hasValidParameters = false; if ( !$hasNamedFct ) { return [ $hasNamedFct, $hasValidParameters ]; } if ( $nextNode && !( $nextNode instanceof Literal && $nextNode->getArg() === "'" ) ) { $hasValidParameters = true; } return [ $hasNamedFct, $hasValidParameters ]; } private function squashLiterals() { $tmp = ''; foreach ( $this->args as $arg ) { if ( !( $arg instanceof Literal ) ) { return; } // Don't squash if there is a macro in the literal if ( preg_match( "/[\\\\]/", $arg->getArg() ) ) { return; } $tmp .= $arg->getArg(); } $this->args = [ new Literal( $tmp ) ]; $this->curly = false; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { // Everything here is for parsing displaystyle, probably refactored to WikiTexVC grammar later $fullRenderedArray = ""; $mmlStyles = []; $currentColor = null; if ( array_key_exists( 'squashLiterals', $state ) ) { $this->squashLiterals(); } for ( $i = 0, $count = count( $this->args ); $i < $count; $i++ ) { $current = $this->args[$i]; if ( isset( $this->args[$i + 1] ) ) { $next = $this->args[$i + 1]; } else { $next = null; } // Check for sideset $foundSideset = $this->checkForSideset( $current, $next ); if ( $foundSideset ) { $state["sideset"] = $foundSideset; // Skipping the succeeding Literal $i++; } // Check for limits $foundLimits = $this->checkForLimits( $current, $next ); if ( $foundLimits[0] ) { $state["limits"] = $foundLimits[0]; if ( $foundLimits[1] ) { continue; } } // Check for Not $foundNot = $this->checkForNot( $current ); if ( $foundNot ) { $state["not"] = true; continue; } // Check for derivatives $foundDeriv = $this->checkForDerivatives( $i + 1, $this->args ); if ( $foundDeriv > 0 ) { // skip the next indices which are derivative characters $i += $foundDeriv; $state["deriv"] = $foundDeriv; } // Check if there is a new color definition and add it to state $foundColorDef = $this->checkForColorDefinition( $current ); if ( $foundColorDef ) { $state["colorDefinitions"][$foundColorDef["name"]] = $foundColorDef; continue; } // Pass preceding color info to state $foundColor = $this->checkForColor( $current ); if ( $foundColor[0] ) { $currentColor = $foundColor[1]; // Skipping the color element itself for rendering continue; } $styleArguments = $this->checkForStyleArgs( $current ); $foundNamedFct = $this->checkForNamedFctArgs( $current, $next ); if ( $foundNamedFct[0] ) { $state["foundNamedFct"] = $foundNamedFct; } if ( $styleArguments ) { $state["styleargs"] = $styleArguments; $mmlStyle = new MMLmstyle( "", $styleArguments ); $fullRenderedArray .= $mmlStyle->getStart(); if ( $next instanceof TexNode && $next->isCurly() ) { // Wrap with style-tags when the next element is a Curly which determines start and end tag. $fullRenderedArray .= $this->createMMLwithContext( $currentColor, $next, $state, $arguments ); $fullRenderedArray .= $mmlStyle->getEnd(); $mmlStyle = null; unset( $state["styleargs"] ); $i++; } else { // Start the style indicator in cases like \textstyle abc $mmlStyles[] = $mmlStyle->getEnd(); } } else { $fullRenderedArray .= $this->createMMLwithContext( $currentColor, $current, $state, $arguments ); } if ( array_key_exists( "not", $state ) ) { unset( $state["not"] ); } if ( array_key_exists( "limits", $state ) ) { unset( $state["limits"] ); } if ( array_key_exists( "deriv", $state ) ) { unset( $state["deriv"] ); } } foreach ( array_reverse( $mmlStyles ) as $mmlStyleEnd ) { $fullRenderedArray .= $mmlStyleEnd; } if ( $this->curly && $this->getLength() > 1 ) { $mmlRow = new MMLmrow(); return $mmlRow->encapsulateRaw( $fullRenderedArray ); } return $fullRenderedArray; } private function createMMLwithContext( ?string $currentColor, TexNode $currentNode, array &$state, array $arguments ): string { if ( $currentColor ) { if ( array_key_exists( "colorDefinitions", $state ) && is_array( $state["colorDefinitions"] ) && array_key_exists( $currentColor, $state["colorDefinitions"] ?? [] ) && is_array( $state["colorDefinitions"][$currentColor] ) && array_key_exists( "hex", $state["colorDefinitions"][$currentColor] ) ) { $displayedColor = $state["colorDefinitions"][$currentColor]["hex"]; } else { $resColor = TexUtil::getInstance()->color( ucfirst( $currentColor ) ); $displayedColor = $resColor ?: $currentColor; } $mmlStyleColor = new MMLmstyle( "", [ "mathcolor" => $displayedColor ] ); $ret = $mmlStyleColor->encapsulateRaw( $currentNode->renderMML( $arguments, $state ) ); } else { $ret = $currentNode->renderMML( $arguments, $state ); } return $this->addDerivativesContext( $state, $ret ); } /** * If derivative was recognized, add the corresponding derivative math operator * to the mml and wrap with msup element. * @param array &$state state indicator which indicates derivative * @param string $mml mathml input * @return string mml with additional mml-elements for derivatives */ public function addDerivativesContext( array &$state, string $mml ): string { if ( array_key_exists( "deriv", $state ) && $state["deriv"] > 0 ) { $msup = new MMLmsup(); $moDeriv = new MMLmo(); if ( $state["deriv"] == 1 ) { $derInfo = "′"; } elseif ( $state["deriv"] == 2 ) { $derInfo = "″"; } elseif ( $state["deriv"] == 3 ) { $derInfo = "‴"; } elseif ( $state["deriv"] == 4 ) { $derInfo = "⁗"; } else { $derInfo = str_repeat( "′", $state["deriv"] ); } $mml = $msup->encapsulateRaw( $mml . $moDeriv->encapsulateRaw( $derInfo ) ); if ( ( $state['foundNamedFct'][0] ?? false ) && !( $state['foundNamedFct'][1] ?? true ) ) { $mml .= MMLParsingUtil::renderApplyFunction(); } } return $mml; } /** @inheritDoc */ public function inCurlies() { if ( isset( $this->args[0] ) && count( $this->args ) == 1 ) { return $this->args[0]->inCurlies(); } else { return '{' . parent::render() . '}'; } } /** @inheritDoc */ public function extractSubscripts() { $y = []; foreach ( $this->args as $x ) { $y = array_merge( $y, $x->extractSubscripts() ); } if ( isset( $this->args[0] ) && ( count( $this->args ) == count( $y ) ) ) { return implode( '', $y ); } return []; } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { if ( $args == null ) { $args = $this->args; } $list = parent::extractIdentifiers( $args ); $outpos = 0; $offset = 0; $int = 0; for ( $inpos = 0; $inpos < count( $list ); $inpos++ ) { $outpos = $inpos - $offset; switch ( $list[$inpos] ) { case '\'': $list[$outpos - 1] .= '\''; $offset++; break; case '\\int': $int++; $offset++; break; case '\\mathrm{d}': case 'd': if ( $int ) { $int--; $offset++; break; } // no break default: if ( isset( $list[0] ) ) { $list[$outpos] = $list[$inpos]; } } } return array_slice( $list, 0, count( $list ) - $offset ); } /** @inheritDoc */ public function getModIdent() { $y = []; foreach ( $this->args as $x ) { $y = array_merge( $y, $x->getModIdent() ); } if ( isset( $this->args[0] ) && ( count( $this->args ) == count( $y ) ) ) { return implode( "", $y ); } return []; } /** * @param TexNode|string ...$elements */ public function push( ...$elements ): TexArray { self::checkInput( $elements ); array_push( $this->args, ...$elements ); return $this; } public function pop() { array_splice( $this->args, 0, 1 ); } /** * @return TexNode|null first value */ public function first() { return $this->args[0] ?? null; } /** * @return TexNode|null second value */ public function second() { return $this->args[1] ?? null; } /** * @param TexNode|string ...$elements */ public function unshift( ...$elements ): TexArray { array_unshift( $this->args, ...$elements ); return $this; } /** * @throws InvalidArgumentException if args not of correct type * @param TexNode[] $args input args * @return void */ private static function checkInput( $args ): void { foreach ( $args as $arg ) { if ( !( $arg instanceof TexNode ) ) { throw new InvalidArgumentException( 'Wrong input type specified in input elements.' ); } } } public function render() { if ( $this->curly ) { return $this->inCurlies(); } return parent::render(); } public function isCurly(): bool { return $this->curly; } public function setCurly( bool $curly = true ): TexArray { $this->curly = $curly; return $this; } /** * @return Generator<TexNode> */ public function getIterator(): Generator { yield from $this->args; } /** * @return TexNode[] */ public function getArgs(): array { return parent::getArgs(); } /** @inheritDoc */ public function offsetExists( $offset ): bool { return isset( $this->args[$offset] ); } /** @inheritDoc */ public function offsetGet( $offset ): ?TexNode { return $this->args[$offset] ?? null; } /** @inheritDoc */ public function offsetSet( $offset, $value ): void { if ( !( $value instanceof TexNode ) ) { throw new InvalidArgumentException( 'TexArray elements must be of type TexNode.' ); } $this->args[$offset] = $value; } /** @inheritDoc */ public function offsetUnset( $offset ): void { unset( $this->args[$offset] ); } public function setRowSpecs( ?LengthSpec $r ) { $this->rowSpecs = $r; } public function getRowSpecs(): ?LengthSpec { return $this->rowSpecs; } } PK ! ��� � Box.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmtext; class Box extends TexNode { /** @var string */ private $fname; /** @var string */ private $arg; public function __construct( string $fname, string $arg ) { parent::__construct( $fname, $arg ); $this->fname = $fname; $this->arg = $arg; } /** * @return string */ public function getFname(): string { return $this->fname; } /** * @return string */ public function getArg(): string { return $this->arg; } /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { return '{' . $this->fname . '{' . $this->arg . '}}'; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { $mrow = new MMLmrow(); $mtext = new MMLmtext(); $arg = $this->getArg(); if ( strlen( $arg ) >= 1 ) { // Replace trailing and leading spaces with special space sign if ( substr( $arg, -1, 1 ) === " " ) { $arg = rtrim( $arg, " " ) . " "; } if ( substr( $arg, 0, 1 ) == " " ) { $arg = " " . ltrim( $arg, " " ); } } return $mrow->encapsulateRaw( $mtext->encapsulateRaw( $arg ) ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { return []; } } PK ! m[��D D UQ.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmi; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmover; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmsup; use MediaWiki\Extension\Math\WikiTexVC\TexUtil; class UQ extends TexNode { /** @var TexNode */ private $base; /** @var TexNode */ private $up; public function __construct( TexNode $base, TexNode $up ) { parent::__construct( $base, $up ); $this->base = $base; $this->up = $up; } /** * @return TexNode */ public function getBase(): TexNode { return $this->base; } /** * @return TexNode */ public function getUp(): TexNode { return $this->up; } /** @inheritDoc */ public function render() { return $this->base->render() . '^' . $this->up->inCurlies(); } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { $mrow = new MMLmrow(); $mmlBase = new MMLmsup(); $base = $this->getBase(); $up = $this->getUp(); $tu = TexUtil::getInstance(); if ( $base instanceof Fun1 && $tu->over_operator( $base->getFname() ) ) { $mmlBase = new MMLmover(); } // If the superscript has empty elements, render them with empty mi elements to prevent browser issues $mi = new MMLmi(); if ( $base instanceof TexArray && $base->getLength() == 0 ) { $baseRendered = $mi->getEmpty(); } else { $baseRendered = $base->renderMML( $arguments, $state ); } if ( $up instanceof TexArray && $up->getLength() == 0 ) { $upRendered = $mi->getEmpty(); } else { // up is inferring a new mrow if it has some content $upRendered = $mrow->encapsulateRaw( $up->renderMML( $arguments, $state ) ); } return $mmlBase->encapsulateRaw( $baseRendered . $upRendered ); } } PK ! � .�� � Dollar.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Dollar extends TexNode { public function __construct( TexArray $value ) { parent::__construct( $value ); } /** @inheritDoc */ public function render() { return '$' . parent::render() . '$'; } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { return []; } } PK ! �ӆ8� � Infix.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Infix extends TexNode { /** @var string */ private $op; /** @var TexArray */ private $arg1; /** @var TexArray */ private $arg2; public function __construct( string $op, TexArray $arg1, TexArray $arg2 ) { parent::__construct( $op, $arg1, $arg2 ); $this->op = $op; $this->arg1 = $arg1; $this->arg2 = $arg2; } /** * @return string */ public function getOp(): string { return $this->op; } /** * @return TexArray */ public function getArg1(): TexArray { return $this->arg1; } /** * @return TexArray */ public function getArg2(): TexArray { return $this->arg2; } /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { return '{' . $this->arg1->render() . ' ' . $this->op . ' ' . $this->arg2->render() . '}'; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { return $this->parseToMML( $this->op, $arguments, null ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { if ( $args == null ) { $args = [ $this->arg1, $this->arg2 ]; } return parent::extractIdentifiers( $args ); } } PK ! �S�!N N TexNode.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use InvalidArgumentException; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseMethods; class TexNode { /** @var list<TexNode|string> */ protected $args; /** * Creates a TexNode * @param TexNode|string ...$args arguments for this node */ public function __construct( ...$args ) { foreach ( $args as $arg ) { if ( !( $arg instanceof TexNode || is_string( $arg ) ) ) { throw new InvalidArgumentException( 'Wrong input type specified in args.' ); } } $this->args = $args; } /** * @param string $input * @param array $passedArgs * @param mixed|null $operatorContent * @return string */ protected function parseToMML( $input, $passedArgs, $operatorContent ): string { $parsed = BaseMethods::checkAndParse( $input, $passedArgs, $operatorContent, $this ); if ( $parsed ) { return $parsed; } $name = strtoupper( self::class ); return BaseMethods::generateMMLError( "Not implemented $name for $input" ); } /** * @return TexNode[]|string[] */ public function getArgs(): array { return $this->args; } /** * @return string */ public function render() { $out = ''; foreach ( $this->args as $child ) { $out .= $child instanceof self ? $child->render() : $child; } return $out; } /** * @param array $arguments * @param array &$state * @return string */ public function renderMML( $arguments = [], &$state = [] ) { return array_reduce( $this->args, function ( $out, $child ) use ( $arguments, $state ) { return $out . $this->renderChildMML( $child, $arguments, $state ); }, '' ); } /** * @param self|string $child * @param array $arguments * @param array &$state * @return string */ public function renderChildMML( $child, $arguments, &$state ) { if ( $child instanceof TexNode ) { return $child->renderMML( $arguments, $state ); } return $child; } /** * @return bool */ public function isEmpty() { foreach ( $this->args ?? [] as $arg ) { if ( $arg instanceof TexNode && !$arg->isEmpty() ) { return false; } if ( is_string( $arg ) && $arg !== '' ) { return false; } } return true; } public function getLength(): int { return count( $this->args ?? [] ); } /** * Wraps the rendered result in curly brackets. * @return string rendered result in curlies. */ public function inCurlies() { return '{' . $this->render() . '}'; } /** * @param self[]|string[]|null $args * @return string[] */ public function extractIdentifiers( $args = null ) { $output = []; foreach ( $args ?? $this->args as $value ) { if ( $value instanceof self ) { $output = array_merge( $output, $value->extractIdentifiers() ); } else { $output[] = $value; } } return $output; } /** * @param string|array $target * @param self[]|string[]|null $args * @return bool */ public function containsFunc( $target, $args = null ) { foreach ( $args ?? $this->args as $value ) { if ( $value instanceof self ) { $ret = $value->containsFunc( $target ); } else { $ret = self::texContainsFunc( $target, $value ); } if ( $ret ) { // Do not check the other items, if some function has been found already. return true; } } return false; } /** * @return string|array */ public function extractSubscripts() { return []; } /** * @return string|array */ public function getModIdent() { return []; } /** * strings can contain function references only in a few specific * forms, which we test for here. * * @param string|array $target * @param string $t Tex to be checked * @return string|bool rendered LaTeX string or false if not found. */ public static function texContainsFunc( $target, string $t ) { // protect against using random strings as keys in target if ( !$t || $t[0] !== '\\' ) { return false; } // may have trailing '(', '[', '\\{' or " " $t = preg_replace( '/(\(|\[|\\\\{| )$/', '', $t ); // special case #1: \\operatorname {someword} $m = preg_match( '/^\\\\operatorname \{([^\\\\]*)}$/', $t ); if ( $m == 1 ) { return self::match( $target, '\\operatorname' ); } // special case #2: \\mbox{\\somefunc} $matches = []; $m = preg_match( '/^\\\\mbox\{(\\\\.*)}$/', $t, $matches ); if ( $m == 1 ) { return self::match( $target, '\\mbox' ) ?: self::match( $target, $matches[1] ); } // special case #3: \\color, \\pagecolor, \\definecolor $matches = []; $m = preg_match( '/^(\\\\(?:page|define)?color) /', $t, $matches ); if ( $m == 1 ) { return self::match( $target, $matches[1] ); } // special case #4: \\mathbb, \\mathrm $matches = []; $m = preg_match( '/^(\\\\math..) \{(\\\\.*)}$/', $t, $matches ); if ( $m == 1 ) { return self::match( $target, $matches[1] ) ?: self::match( $target, $matches[2] ); } return self::match( $target, $t ); } /** * Matches a string against a string, array, or set target. * @param string|array $target * @param string $str * @return bool|string matching value or false */ public static function match( $target, string $str ) { if ( is_string( $target ) ) { return $target === $str ? $str : false; } foreach ( $target as $key => $value ) { // In javascript both types are used to comparison in match functionality if ( is_string( $key ) ) { if ( $key === $str ) { return $str; } } elseif ( is_array( $value ) ) { if ( self::match( $value, $str ) !== false ) { return $str; } } elseif ( $value === $str ) { return $str; } } return false; } public function isCurly(): bool { return false; } } PK ! �W�� � Big.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Big extends TexNode { /** @var string */ private $fname; /** @var string */ private $arg; public function __construct( string $fname, string $arg ) { parent::__construct( $fname, $arg ); $this->fname = $fname; $this->arg = $arg; } /** * @return string */ public function getFname(): string { return $this->fname; } /** * @return string */ public function getArg(): string { return $this->arg; } /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { return '{' . $this->fname . ' ' . $this->arg . '}'; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ): string { return $this->parseToMML( $this->fname, $arguments, null ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { return []; } } PK ! �(�&� � Fun1.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmo; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmover; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; use MediaWiki\Extension\Math\WikiTexVC\TexUtil; class Fun1 extends TexNode { /** @var string */ protected $fname; /** @var TexNode */ protected $arg; /** @var TexUtil */ private $tu; public function __construct( string $fname, TexNode $arg ) { parent::__construct( $fname, $arg ); $this->fname = $fname; $this->arg = $arg; $this->tu = TexUtil::getInstance(); } /** * @return string */ public function getFname(): string { return $this->fname; } /** * @return TexNode */ public function getArg(): TexNode { return $this->arg; } /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { return '{' . $this->fname . ' ' . $this->arg->inCurlies() . '}'; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { return $this->parseToMML( $this->fname, $arguments, null ); } public function createMover( string $inner, array $moArgs = [] ): string { $mrow = new MMLmrow(); $mo = new MMLmo( "", $moArgs ); $mover = new MMLmover(); $ret = $mrow->encapsulateRaw( $mrow->encapsulateRaw( $mover->encapsulateRaw( $this->args[1]->renderMML() . $mo->encapsulateRaw( $inner ) ) ) ); return $ret; } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { if ( $args == null ) { $args = [ $this->arg ]; } $letterMods = array_keys( $this->tu->getBaseElements()['is_letter_mod'] ); if ( in_array( $this->fname, $letterMods, true ) ) { $ident = $this->arg->getModIdent(); if ( !isset( $ident[0] ) ) { return parent::extractIdentifiers( $args ); } // in difference to javascript code: taking first element of array here. return [ $this->fname . '{' . $ident[0] . '}' ]; } elseif ( array_key_exists( $this->fname, $this->tu->getBaseElements()['ignore_identifier'] ) ) { return []; } return parent::extractIdentifiers( $args ); } /** @inheritDoc */ public function extractSubscripts() { return $this->getSubs( $this->arg->extractSubscripts() ); } /** @inheritDoc */ public function getModIdent() { return $this->getSubs( $this->arg->getModIdent() ); } private function getSubs( array $subs ): array { $letterMods = array_keys( $this->tu->getBaseElements()['is_letter_mod'] ); if ( isset( $subs[0] ) && in_array( $this->fname, $letterMods, true ) ) { // in difference to javascript code: taking first element of array here. return [ $this->fname . '{' . $subs[0] . '}' ]; } return []; } } PK ! 0�K* * Declh.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; class Declh extends TexNode { /** @var string */ private $fname; /** @var TexArray */ private $arg; public function __construct( string $fname, TexArray $arg ) { parent::__construct( $fname, $arg ); $this->fname = $fname; $this->arg = $arg; } /** * @return string */ public function getFname(): string { return $this->fname; } /** * @return TexArray */ public function getArg(): TexArray { return $this->arg; } /** @inheritDoc */ public function inCurlies() { return $this->render(); } /** @inheritDoc */ public function render() { return '{' . $this->fname . ' ' . $this->arg->inCurlies() . '}'; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { return $this->parseToMML( $this->fname, $arguments, null ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { if ( $args == null ) { $args = [ $this->arg ]; } $identifier = parent::extractIdentifiers( $args ); if ( isset( $identifier[0] ) ) { return [ implode( '', $identifier ) ]; } return $identifier; } /** @inheritDoc */ public function extractSubscripts() { $f = $this->fname; // @see // http://tex.stackexchange.com/questions/98406/which-command-should-i-use-for-textual-subscripts-in-math-mode // cf https://phabricator.wikimedia.org/T56818 a is always RM // for f there are only four cases switch ( $f ) { case '\\rm': $f = '\\mathrm'; break; case '\\it': $f = '\\mathit'; break; case '\\cal': $f = '\\mathcal'; break; case '\\bf': $f = '\\mathbf'; } $x = $this->arg->extractSubscripts(); if ( isset( $x[0] ) ) { return [ $f . '{' . $x . '}' ]; } return parent::extractSubscripts(); } } PK ! �&*�� � DQ.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseParsing; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmsub; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmunder; use MediaWiki\Extension\Math\WikiTexVC\TexUtil; class DQ extends TexNode { /** @var TexNode */ private $base; /** @var TexNode */ private $down; public function __construct( TexNode $base, TexNode $down ) { parent::__construct( $base, $down ); $this->base = $base; $this->down = $down; } /** * @return TexNode */ public function getBase(): TexNode { return $this->base; } /** * @return TexNode */ public function getDown(): TexNode { return $this->down; } /** @inheritDoc */ public function render() { return $this->base->render() . '_' . $this->down->inCurlies(); } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { if ( array_key_exists( "limits", $state ) ) { // A specific DQ case with preceding limits, just invoke the limits parsing manually. return BaseParsing::limits( $this, $arguments, $state, "" ); } if ( !$this->isEmpty() ) { if ( $this->getBase()->containsFunc( "\underbrace" ) ) { $outer = new MMLmunder(); } else { $outer = new MMLmsub(); if ( ( $state['styleargs']['displaystle'] ?? 'true' ) === 'true' ) { $tu = TexUtil::getInstance(); if ( $tu->operator( trim( $this->base->render() ) ) ) { $outer = new MMLmunder(); } } } // Otherwise use default fallback $mmlMrow = new MMLmrow(); $inner_state = [ 'styleargs' => $state['styleargs'] ?? [] ]; $baseRendering = $this->base->renderMML( $arguments, $inner_state ); // In cases with empty curly preceding like: "{}_pF_q" or _{1} if ( trim( $baseRendering ) === "" ) { $baseRendering = ( new MMLmrow() )->getEmpty(); } return $outer->encapsulateRaw( $baseRendering . $mmlMrow->encapsulateRaw( $this->down->renderMML( $arguments, $state ) ) ); } return ""; } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { $d = $this->down->extractSubscripts(); $b = $this->base->extractIdentifiers(); if ( is_array( $b ) && count( $b ) > 1 ) { return parent::extractIdentifiers(); } if ( isset( $b[0] ) && $b[0] === '\'' ) { return array_merge( $b, $d ); } if ( isset( $d[0] ) && isset( $b[0] ) ) { if ( $b[0] === '\\int' ) { return array_merge( $b, $d ); } return [ $b[0] . '_{' . $d[0] . '}' ]; } return parent::extractIdentifiers(); } /** @inheritDoc */ public function extractSubscripts() { $d = array_merge( [], $this->down->extractSubscripts() ); $b = $this->base->extractSubscripts(); if ( isset( $b[0] ) && isset( $d[0] ) ) { return [ $b[0] . '_{' . implode( '', $d ) . '}' ]; } return parent::extractSubscripts(); } /** @inheritDoc */ public function getModIdent() { $d = $this->down->extractSubscripts(); $b = $this->base->getModIdent(); if ( isset( $b[0] ) && $b[0] === '\'' ) { return []; } if ( isset( $d[0] ) && isset( $b[0] ) ) { return [ $b[0] . '_{' . $d[0] . '}' ]; } return parent::getModIdent(); } } PK ! �`ѳ � Lr.phpnu �Iw�� <?php declare( strict_types = 1 ); namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\BaseMethods; use MediaWiki\Extension\Math\WikiTexVC\MMLmappings\TexConstants\TexClass; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmo; use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; class Lr extends TexNode { /** @var string */ private $left; /** @var string */ private $right; /** @var TexArray */ private $arg; public function __construct( string $left, string $right, TexArray $arg ) { parent::__construct( $left, $right, $arg ); $this->left = $left; $this->right = $right; $this->arg = $arg; } /** * @return string */ public function getLeft(): string { return $this->left; } /** * @return string */ public function getRight(): string { return $this->right; } /** * @return TexArray */ public function getArg(): TexArray { return $this->arg; } /** @inheritDoc */ public function inCurlies() { return '{' . $this->render() . '}'; } /** @inheritDoc */ public function render() { return '\\left' . $this->left . $this->arg->render() . '\\right' . $this->right; } /** @inheritDoc */ public function renderMML( $arguments = [], &$state = [] ) { // TBD set attributes for right AND left correctly $rightAttrs = []; if ( $this->right == "." ) { $rightAttrs = [ "fence" => "true", "stretchy" => "true", "symmetric" => "true" ]; } $bm = new BaseMethods(); $left = $bm->checkAndParseDelimiter( $this->left, $this, [], null, true, TexClass::OPEN ); if ( !$left ) { $moLeft = new MMLmo( TexClass::OPEN, [] ); $left = $moLeft->encapsulateRaw( $this->right ); } $right = $bm->checkAndParseDelimiter( $this->right, $this, $rightAttrs, null, true, TexClass::CLOSE ); if ( !$right ) { $moRight = new MMLmo( TexClass::CLOSE, $rightAttrs ); $right = $moRight->encapsulateRaw( $this->right ); } // Don't apply outer ' inside the LR structure unset( $state['deriv'] ); $inner = $this->getArg()->renderMML( [], $state ); $mrow = new MMLmrow( TexClass::INNER ); return $mrow->encapsulateRaw( $left . $inner . $right ); } private function mmlTranslate( string $input ): string { switch ( trim( $input ) ) { case "\\vert": return "|"; default: return $input; } } /** @inheritDoc */ public function containsFunc( $target, $args = null ) { if ( $args == null ) { $args = [ '\\left', '\\right', $this->arg ]; } return parent::containsFunc( $target, $args ); } /** @inheritDoc */ public function extractIdentifiers( $args = null ) { if ( $args == null ) { $args = [ $this->arg ]; } return parent::extractIdentifiers( $args ); } } PK ! ��ʷ� � Fun1nb.phpnu �Iw�� PK ! h⼠� � Fun4.phpnu �Iw�� PK ! n��� � S ChemWord.phpnu �Iw�� PK ! "!��_ _ Fun2sq.phpnu �Iw�� PK ! ��� � � Literal.phpnu �Iw�� PK ! F�V0 0 �) Mhchem.phpnu �Iw�� PK ! g�+S 8+ Matrix.phpnu �Iw�� PK ! �[�Z\ \ �@ Fun2nb.phpnu �Iw�� PK ! ��l� %B FQ.phpnu �Iw�� PK ! S�� lN Fun2.phpnu �Iw�� PK ! ��» � �S ChemFun2u.phpnu �Iw�� PK ! ܟe �W LengthSpec.phpnu �Iw�� PK ! B&��9? 9? [ TexArray.phpnu �Iw�� PK ! ��� � ~� Box.phpnu �Iw�� PK ! m[��D D R� UQ.phpnu �Iw�� PK ! � .�� � ̧ Dollar.phpnu �Iw�� PK ! �ӆ8� � �� Infix.phpnu �Iw�� PK ! �S�!N N î TexNode.phpnu �Iw�� PK ! �W�� � L� Big.phpnu �Iw�� PK ! �(�&� � E� Fun1.phpnu �Iw�� PK ! 0�K* * n� Declh.phpnu �Iw�� PK ! �&*�� � �� DQ.phpnu �Iw�� PK ! �`ѳ � �� Lr.phpnu �Iw�� PK � ��
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0.01 |
proxy
|
phpinfo
|
ÐаÑтройка