mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-30 10:25:29 +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.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
|
||||
</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>
|
||||
<file>.</file>
|
||||
<arg name="extensions" value="php" />
|
||||
|
|
|
@ -83,13 +83,24 @@ class JsonToMathML extends Maintenance {
|
|||
}
|
||||
}
|
||||
$mmlLaTeXML = $this->fetchMathML( $entry['tex'], $entry['type'], 'latexml' );
|
||||
|
||||
$allEntries[] = [
|
||||
$entryToAdd = [
|
||||
"tex" => $entry['tex'],
|
||||
"type" => $entry['type'],
|
||||
"mmlMathoid" => $mmlMathoid,
|
||||
"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 ) {
|
||||
$allEntries[] = [
|
||||
"tex" => $entry['tex'],
|
||||
|
@ -140,6 +151,20 @@ class JsonToMathML extends Maintenance {
|
|||
];
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue