mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-30 18:35:12 +00:00
Implement mhchemParser maintenance in PHP
Change-Id: I4c97d493a35b2ae536422c0121eec6a33c3ce7ec
This commit is contained in:
parent
e0d66eab55
commit
8c5a694656
|
@ -10,6 +10,10 @@
|
||||||
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
|
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
|
||||||
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
|
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
|
||||||
</rule>
|
</rule>
|
||||||
|
<rule ref="Generic.Files.LineLength.TooLong">
|
||||||
|
<exclude-pattern>/src/TexVC/Mhchem/MhchemPatterns.php</exclude-pattern>
|
||||||
|
<exclude-pattern>/src/TexVC/Mhchem/MhchemStateMachines.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
<exclude-pattern>/src/TexVC/Parser.php</exclude-pattern>
|
<exclude-pattern>/src/TexVC/Parser.php</exclude-pattern>
|
||||||
<file>.</file>
|
<file>.</file>
|
||||||
<arg name="extensions" value="php" />
|
<arg name="extensions" value="php" />
|
||||||
|
|
|
@ -83,13 +83,24 @@ class JsonToMathML extends Maintenance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$mmlLaTeXML = $this->fetchMathML( $entry['tex'], $entry['type'], 'latexml' );
|
$mmlLaTeXML = $this->fetchMathML( $entry['tex'], $entry['type'], 'latexml' );
|
||||||
|
$entryToAdd = [
|
||||||
$allEntries[] = [
|
|
||||||
"tex" => $entry['tex'],
|
"tex" => $entry['tex'],
|
||||||
"type" => $entry['type'],
|
"type" => $entry['type'],
|
||||||
"mmlMathoid" => $mmlMathoid,
|
"mmlMathoid" => $mmlMathoid,
|
||||||
"mmlLaTeXML" => $mmlLaTeXML
|
"mmlLaTeXML" => $mmlLaTeXML
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ( array_key_exists( "texNew", $entry ) ) {
|
||||||
|
$entryToAdd["texNew"] = $entry["texNew"];
|
||||||
|
}
|
||||||
|
if ( array_key_exists( "typeC", $entry ) ) {
|
||||||
|
$entryToAdd["typeC"] = $entry["typeC"];
|
||||||
|
}
|
||||||
|
if ( array_key_exists( "description", $entry ) ) {
|
||||||
|
$entryToAdd["description"] = $entry["description"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$allEntries[] = $entryToAdd;
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
$allEntries[] = [
|
$allEntries[] = [
|
||||||
"tex" => $entry['tex'],
|
"tex" => $entry['tex'],
|
||||||
|
@ -140,6 +151,20 @@ class JsonToMathML extends Maintenance {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
// Example file Mhchemv4tex.json
|
||||||
|
foreach ( $fileData as $group => $cases ) {
|
||||||
|
foreach ( $cases as $case ) {
|
||||||
|
$inputF[] = [
|
||||||
|
"description" => $group,
|
||||||
|
"tex" => $case["tex"],
|
||||||
|
"texNew" => $case["texNew"],
|
||||||
|
"type" => "chem",
|
||||||
|
"typeC" => $case["type"]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $inputF;
|
return $inputF;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue