build: Fix line indents

Change-Id: If3be1b7575a1570e425847f559821e7408e5ec24
这个提交包含在:
Umherirrender 2024-03-10 22:46:31 +01:00
父节点 457b953dd0
当前提交 555ed8e29f
共有 6 个文件被更改,包括 157 次插入150 次删除

查看文件

@ -10,7 +10,6 @@
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeClassBrace.BraceNotOnOwnLine" />
<exclude name="Generic.WhiteSpace.ScopeIndent" />
</rule>
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>/src/WikiTexVC/Mhchem/MhchemPatterns.php</exclude-pattern>

查看文件

@ -335,11 +335,11 @@ class MathWikibaseConnector {
$entityRevision = $this->entityRevisionLookup->getEntityRevision( $entityId );
$innerEntity = $entityRevision->getEntity();
if ( $innerEntity instanceof Item ) {
$globalID = $this->site->getGlobalId();
if ( $innerEntity->hasLinkToSite( $globalID ) ) {
$siteLink = $innerEntity->getSiteLink( $globalID );
return $this->site->getPageUrl( $siteLink->getPageName() );
}
$globalID = $this->site->getGlobalId();
if ( $innerEntity->hasLinkToSite( $globalID ) ) {
$siteLink = $innerEntity->getSiteLink( $globalID );
return $this->site->getPageUrl( $siteLink->getPageName() );
}
}
} catch ( StorageException $e ) {
$this->logger->warning(

查看文件

@ -46,9 +46,9 @@ class BaseMethods {
$resFct = BaseMappings::getSpecialByKey( $input );
if ( $resFct == null ) {
$resFct = BaseMappings::getCancelByKey( $input );
if ( $resFct == null ) {
$resFct = BaseMappings::getMhChemByKey( $input );
}
if ( $resFct == null ) {
$resFct = BaseMappings::getMhChemByKey( $input );
}
}
}
}

查看文件

@ -62,7 +62,7 @@ class MhchemStateMachines {
// 2a. Normalize actions into array: 'text=' ==> [{type_:'text='}]
$p = $d2;
if ( is_string( $p["action_"] ) ) {
$p["action_"] = [ $p["action_"] ];
$p["action_"] = [ $p["action_"] ];
}
$p["action_"] = array_merge( [], $p["action_"] );
@ -821,11 +821,11 @@ class MhchemStateMachines {
"actions" => [
'state of aggregation' => function ( $_buffer, $m ) {
return [ "type_" => 'state of aggregation subscript',
"p1" => $this->mhchemParser->go( $m, 'o' ) ];
"p1" => $this->mhchemParser->go( $m, 'o' ) ];
},
'color-output' => function ( $_buffer, $m ) {
return [ "type_" => 'color', "color1" => $m[0] ?? null,
"color2" => $this->mhchemParser->go( $m[1] ?? null, 'pq' ) ];
"color2" => $this->mhchemParser->go( $m[1] ?? null, 'pq' ) ];
}
]
],
@ -941,7 +941,8 @@ class MhchemStateMachines {
return $ret;
}
return null;
} ]
}
]
],
'tex-math tight' => [
"transitions" => static::mhchemCreateTransitions( [
@ -1013,84 +1014,85 @@ class MhchemStateMachines {
],
'(-)(9)^(-9)' => [
'0' => [ "action_" => 'number^', "nextState" => 'a' ]
],
'(-)(9.,9)(e)(99)' => [
'0' => [ "action_" => 'enumber', "nextState" => 'a' ]
],
'space' => [
'0|a' => [ "action_" => [] ]
],
'pm-operator' => [
'0|a' => [ "action_" => [ [ "type_" => 'operator', "option" => '\\pm' ] ], "nextState" => '0' ]
],
'operator' => [
'0|a' => [ "action_" => 'copy', "nextState" => '0' ]
],
'//' => [
'd' => [ "action_" => 'o=', "nextState" => '/' ]
],
'/' => [
'd' => [ "action_" => 'o=', "nextState" => '/' ]
],
'{...}|else' => [
'0|d' => [ "action_" => 'd=', "nextState" => 'd' ],
'a' => [ "action_" => [ 'space', 'd=' ], "nextState" => 'd' ],
'/|q' => [ "action_" => 'q=', "nextState" => 'q' ]
]
] ),
"actions" => [
'enumber' => function ( $_buffer, $m ) {
$ret = [];
if ( MU::issetJS( $m[0] ?? null ) && ( $m[0] === "+-" || $m[0] === "+/-" ) ) {
$ret[] = "\\pm ";
} elseif ( MU::issetJS( $m[0] ?? null ) ) {
$ret[] = $m[0];
}
if ( MU::issetJS( $m[1] ?? null ) ) {
MhchemUtil::concatArray( $ret, $this->mhchemParser->go( $m[1], 'pu-9,9' ) );
],
'(-)(9.,9)(e)(99)' => [
'0' => [ "action_" => 'enumber', "nextState" => 'a' ]
],
'space' => [
'0|a' => [ "action_" => [] ]
],
'pm-operator' => [
'0|a' => [ "action_" => [ [ "type_" => 'operator', "option" => '\\pm' ] ], "nextState" => '0' ]
],
'operator' => [
'0|a' => [ "action_" => 'copy', "nextState" => '0' ]
],
'//' => [
'd' => [ "action_" => 'o=', "nextState" => '/' ]
],
'/' => [
'd' => [ "action_" => 'o=', "nextState" => '/' ]
],
'{...}|else' => [
'0|d' => [ "action_" => 'd=', "nextState" => 'd' ],
'a' => [ "action_" => [ 'space', 'd=' ], "nextState" => 'd' ],
'/|q' => [ "action_" => 'q=', "nextState" => 'q' ]
]
] ),
"actions" => [
'enumber' => function ( $_buffer, $m ) {
$ret = [];
if ( MU::issetJS( $m[0] ?? null ) && ( $m[0] === "+-" || $m[0] === "+/-" ) ) {
$ret[] = "\\pm ";
} elseif ( MU::issetJS( $m[0] ?? null ) ) {
$ret[] = $m[0];
}
if ( MU::issetJS( $m[1] ?? null ) ) {
MhchemUtil::concatArray( $ret, $this->mhchemParser->go( $m[1], 'pu-9,9' ) );
if ( MU::issetJS( ( $m[2] ?? null ) ) ) {
if ( preg_match( "/[,.]/", $m[2] ) ) {
MhchemUtil::concatArray( $ret,
$this->mhchemParser->go( $m[2], 'pu-9,9' ) );
} else {
$ret[] = $m[2];
if ( MU::issetJS( ( $m[2] ?? null ) ) ) {
if ( preg_match( "/[,.]/", $m[2] ) ) {
MhchemUtil::concatArray( $ret,
$this->mhchemParser->go( $m[2], 'pu-9,9' ) );
} else {
$ret[] = $m[2];
}
}
if ( MU::issetJS( $m[3] ?? null ) || MU::issetJS( $m[4] ?? null ) ) {
if ( $m[3] === "e" || $m[4] === "*" ) {
$ret[] = [ "type_" => 'cdot' ];
} else {
$ret[] = [ "type_" => 'times' ];
}
}
}
if ( MU::issetJS( $m[3] ?? null ) || MU::issetJS( $m[4] ?? null ) ) {
if ( $m[3] === "e" || $m[4] === "*" ) {
$ret[] = [ "type_" => 'cdot' ];
} else {
$ret[] = [ "type_" => 'times' ];
}
if ( MU::issetJS( $m[5] ?? null ) ) {
$ret[] = "10^{" . $m[5] . "}";
}
}
if ( MU::issetJS( $m[5] ?? null ) ) {
$ret[] = "10^{" . $m[5] . "}";
}
return $ret;
},
'number^' => function ( $_buffer, $m ) {
$ret = [];
if ( isset( $m[0] ) && ( $m[0] === "+-" || $m[0] === "+/-" ) ) {
$ret[] = "\\pm ";
} elseif ( isset( $m[0] ) ) {
$ret[] = $m[0];
}
MhchemUtil::concatArray( $ret,
$this->mhchemParser->go( $m[1] ?? null, 'pu-9,9' ) );
$ret[] = "^{" . ( $m[2] ?? "" ) . "}";
return $ret;
},
'operator' => static function ( $_buffer, $m, $p1 ) {
return [ "type_" => 'operator', "kind_" => $p1 ?? $m ];
},
'space' => static function () { return [ "type_" => 'pu-space-1' ];
},
'output' => function ( &$buffer ) {
return $ret;
},
'number^' => function ( $_buffer, $m ) {
$ret = [];
if ( isset( $m[0] ) && ( $m[0] === "+-" || $m[0] === "+/-" ) ) {
$ret[] = "\\pm ";
} elseif ( isset( $m[0] ) ) {
$ret[] = $m[0];
}
MhchemUtil::concatArray( $ret,
$this->mhchemParser->go( $m[1] ?? null, 'pu-9,9' ) );
$ret[] = "^{" . ( $m[2] ?? "" ) . "}";
return $ret;
},
'operator' => static function ( $_buffer, $m, $p1 ) {
return [ "type_" => 'operator', "kind_" => $p1 ?? $m ];
},
'space' => static function () {
return [ "type_" => 'pu-space-1' ];
},
'output' => function ( &$buffer ) {
$md = $this->mhchemParser->getPatterns()->match( '{(...)}', $buffer["d"] ?? "" );
if ( $md && $md["remainder"] === '' ) {
$buffer["d"] = $md["match_"];
@ -1105,7 +1107,6 @@ class MhchemStateMachines {
"{}^{\\circ}C", $buffer["d"] );
$buffer["d"] = preg_replace( '/\x{00B0}F|\^oF|\^{o}F/u',
"{}^{\\circ}C", $buffer["d"] );
}
if ( isset( $buffer["q"] ) ) {
$buffer["q"] = preg_replace( "/\x{00B0}C|\^oC|\^{o}C/u",
@ -1135,7 +1136,7 @@ class MhchemStateMachines {
unset( $buffer[$key] );
}
return $ret;
}
}
],
],
'pu-2' => [
@ -1195,54 +1196,56 @@ class MhchemStateMachines {
'0' => [ "action_" => [ 'output-0', 'comma' ], "nextState" => 'o' ]
],
'.' => [
'0' => [ "action_" => [ 'output-0', 'copy' ], "nextState" => 'o' ]
],
'0' => [ "action_" => [ 'output-0', 'copy' ], "nextState" => 'o' ]
],
'else' => [ '*' => [ "action_" => 'text=' ] ]
] ),
"actions" => [
'comma' => static function () { return [ "type_" => 'commaDecimal' ];
},
'output-0' => static function ( &$buffer ) {
$ret = [];
$buffer["text_"] ??= "";
if ( strlen( $buffer["text_"] ) > 4 ) {
$a = strlen( $buffer["text_"] ) % 3;
if ( $a === 0 ) {
$a = 3;
"actions" => [
'comma' => static function () {
return [ "type_" => 'commaDecimal' ];
},
'output-0' => static function ( &$buffer ) {
$ret = [];
$buffer["text_"] ??= "";
if ( strlen( $buffer["text_"] ) > 4 ) {
$a = strlen( $buffer["text_"] ) % 3;
if ( $a === 0 ) {
$a = 3;
}
for ( $i = strlen( $buffer["text_"] ) - 3; $i > 0; $i -= 3 ) {
$ret[] = substr( $buffer["text_"], $i, 3 );
$ret[] = [ "type_" => '1000 separator' ];
}
$ret[] = substr( $buffer["text_"], 0, $a );
$ret = array_reverse( $ret );
} else {
$ret[] = $buffer["text_"];
}
for ( $i = strlen( $buffer["text_"] ) - 3; $i > 0; $i -= 3 ) {
$ret[] = substr( $buffer["text_"], $i, 3 );
$ret[] = [ "type_" => '1000 separator' ];
foreach ( $buffer as $key => $value ) {
unset( $buffer[$key] );
}
$ret[] = substr( $buffer["text_"], 0, $a );
$ret = array_reverse( $ret );
} else {
$ret[] = $buffer["text_"];
}
foreach ( $buffer as $key => $value ) {
unset( $buffer[$key] );
}
return $ret;
},
'output-o' => static function ( &$buffer ) {
$ret = [];
$buffer["text_"] ??= "";
if ( strlen( $buffer["text_"] ) > 4 ) {
$a = strlen( $buffer["text_"] ) - 3;
for ( $i = 0; $i < $a; $i += 3 ) {
$ret[] = substr( $buffer["text_"], $i, 3 );
$ret[] = [ "type_" => '1000 separator' ];
return $ret;
},
'output-o' => static function ( &$buffer ) {
$ret = [];
$buffer["text_"] ??= "";
if ( strlen( $buffer["text_"] ) > 4 ) {
$a = strlen( $buffer["text_"] ) - 3;
for ( $i = 0; $i < $a; $i += 3 ) {
$ret[] = substr( $buffer["text_"], $i, 3 );
$ret[] = [ "type_" => '1000 separator' ];
}
$ret[] = substr( $buffer["text_"], $i );
} else {
$ret[] = $buffer["text_"];
}
$ret[] = substr( $buffer["text_"], $i );
} else {
$ret[] = $buffer["text_"];
foreach ( $buffer as $key => $value ) {
unset( $buffer[$key] );
}
return $ret;
}
foreach ( $buffer as $key => $value ) {
unset( $buffer[$key] );
}
return $ret;
}
] ]
]
]
];
}

查看文件

@ -34,12 +34,12 @@ class TexArray extends TexNode {
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" ];
case "\\scriptstyle":
return [ "displaystyle" => "false", "scriptlevel" => "1" ];
case "\\scriptscriptstyle":
return [ "displaystyle" => "false", "scriptlevel" => "2" ];
case "\\textstyle":
return [ "displaystyle" => "false", "scriptlevel" => "0" ];
}
}
return null;

查看文件

@ -29,31 +29,34 @@ class AllTest extends MediaWikiUnitTestCase {
'\\llcorner\\lrcorner\\rangle\\rbrace\\rceil\\rfloor\\rightleftharpoons' .
'\\twoheadleftarrow\\twoheadrightarrow\\ulcorner\\uparrow\\Uparrow' .
'\\updownarrow\\Updownarrow\\urcorner\\Vert\\vert\\lbrack\\rbrack';
$DELIMITERS2 = array_map( static function ( $f ) { return '\\' . $f;
$DELIMITERS2 = array_map( static function ( $f ) {
return '\\' . $f;
}, explode( '\\', $delim2 ) );
array_shift( $DELIMITERS2 );
$delim3 = '\\darr\\dArr\\Darr\\lang\\rang\\uarr\\uArr\\Uarr';
$DELIMITERS3 = array_map( static function ( $f ) { return '\\' . $f;
$DELIMITERS3 = array_map( static function ( $f ) {
return '\\' . $f;
}, explode( '\\', $delim3 ) );
array_shift( $DELIMITERS3 );
return [
'Box functions' =>
[ [
"input" =>
'Box functions' => [
[
"input" =>
"\\text {-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}} " .
"\\mbox {-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}} " .
"\\hbox {-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}} " .
"\\vbox {-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}} ",
"output" =>
"output" =>
"{\\text{-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}}}" .
"{\\mbox{-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}}}" .
"{\\hbox{-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}}}" .
"{\\vbox{-0-9a-zA-Z+*,=():/;?.!'` \u{0080}-\u{00FF}}}"
] ],
'Box functions (2)' =>
[ [
]
],
'Box functions (2)' => [
[
'input' => '{\\text{ABC}}{\\mbox{ABC}}{\\hbox{ABC}}{\\vbox{ABC}}',
'skipOcaml' => true /* extra braces in ocaml version */
]
@ -185,7 +188,7 @@ class AllTest extends MediaWikiUnitTestCase {
'\\mbox{\\varstigma} '
]
],
'Literals (2\')' => [
'Literals (2\')' => [
[
/* We can parse what we emit (but the ocaml version can't) */
'input' =>
@ -263,7 +266,8 @@ class AllTest extends MediaWikiUnitTestCase {
'\\mathrm {T} \\vartheta \\mbox{\\coppa} \\wp \\mathrm {Z} '
]
],
'Big' => [ self::bigs( $DELIMITERS1, $DELIMITERS2 ),
'Big' => [
self::bigs( $DELIMITERS1, $DELIMITERS2 ),
],
'Delimiters (1)' => [
[
@ -425,14 +429,15 @@ class AllTest extends MediaWikiUnitTestCase {
'DECLh' => [ [
'input' => '{abc \\rm def \\it ghi \\cal jkl \\bf mno}',
'output' => '{abc{\\rm {def{\\it {ghi{\\cal {jkl{\\bf {mno}}}}}}}}}'
]
]
],
'litsq_zq' => [ [
'input' => ']^2',
'output' => ']^{2}'
]
]
],
'Matrices' => [ self::matrices(),
'Matrices' => [
self::matrices(),
],
'Matrices (2)' => [
[
@ -531,7 +536,7 @@ class AllTest extends MediaWikiUnitTestCase {
private static function matrices() {
$ENV = [ 'matrix', 'pmatrix', 'bmatrix', 'Bmatrix', 'vmatrix', 'Vmatrix',
'array', 'align', 'alignat', 'smallmatrix', 'cases' ];
'array', 'align', 'alignat', 'smallmatrix', 'cases' ];
$input = implode( '', array_map( static function ( $env ) {
return '\\begin{' . $env . '}' . AllTest::argi( $env ) . ' a & b \\\\\\hline c & d \\end{' . $env . '}';