mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-24 07:34:22 +00:00
Merge "Render MathML for some letters used in mhchem"
This commit is contained in:
commit
383428b478
|
@ -774,6 +774,20 @@ class BaseMappings {
|
|||
"varointclockwise" => [ 'oint', '\u2232', [ "texClass" => TexClass::OP ] ],
|
||||
"\\P" => [ 'oint', '\u00B6', [ "texClass" => TexClass::OP ] ],
|
||||
'textvisiblespace' => [ 'Insert', '\u2423' ], // From TextCompMappings.js (only makro it seems)
|
||||
"Alpha" => [ 'customLetters', "A" ],
|
||||
"Beta" => [ 'customLetters', "B" ],
|
||||
"Chi" => [ 'customLetters', "X" ],
|
||||
"Epsilon" => [ 'customLetters', "E" ],
|
||||
"Eta" => [ 'customLetters', "H" ],
|
||||
"Iota" => [ 'customLetters', "I" ],
|
||||
"Kappa" => [ 'customLetters', "K" ],
|
||||
"Mu" => [ 'customLetters', "M" ],
|
||||
"Nu" => [ 'customLetters', "N" ],
|
||||
"Omicron" => [ 'customLetters', "O" ],
|
||||
"Rho" => [ 'customLetters', "P" ],
|
||||
"Tau" => [ 'customLetters', "T" ],
|
||||
"Zeta" => [ 'customLetters', "Z" ],
|
||||
"ca" => [ "customLetters", "∼", true ]
|
||||
];
|
||||
|
||||
private const ALL = [
|
||||
|
|
|
@ -211,6 +211,18 @@ class BaseParsing {
|
|||
return "tbd chemCustom";
|
||||
}
|
||||
|
||||
public static function customLetters( $node, $passedArgs, $operatorContent, $name, $char, $isOperator = false ) {
|
||||
$mrow = new MMLmrow();
|
||||
|
||||
if ( $isOperator ) {
|
||||
$mo = new MMLmo();
|
||||
return $mrow->encapsulateRaw( $mo->encapsulateRaw( $char ) );
|
||||
}
|
||||
|
||||
$mi = new MMLmi( "", [ "mathvariant" => "normal" ] );
|
||||
return $mrow->encapsulateRaw( $mi->encapsulateRaw( $char ) );
|
||||
}
|
||||
|
||||
public static function cFrac( $node, $passedArgs, $operatorContent, $name ) {
|
||||
$mrow = new MMLmrow();
|
||||
$mfrac = new MMLmfrac();
|
||||
|
|
|
@ -15,6 +15,39 @@ use MediaWikiUnitTestCase;
|
|||
*/
|
||||
final class MhchemBasicMMLTest extends MediaWikiUnitTestCase {
|
||||
|
||||
public static function provideTestCasesLetters() {
|
||||
return [
|
||||
[ "Alpha" , "A" ],
|
||||
[ "Beta" , "B" ] ,
|
||||
[ "Chi" , "X" ],
|
||||
[ "Epsilon" , "E" ],
|
||||
[ "Eta" , "H" ],
|
||||
[ "Iota" , "I" ],
|
||||
[ "Kappa" , "K" ],
|
||||
[ "Mu" , "M" ],
|
||||
[ "Nu" , "N" ],
|
||||
[ "Omicron" , "O" ],
|
||||
[ "Rho" , "P" ],
|
||||
[ "Tau" , "T" ],
|
||||
[ "Zeta" , "Z" ]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestCasesLetters
|
||||
*/
|
||||
public function testmhchemLetters( $case, $result ) {
|
||||
$input = "\ce{\\" . $case . " \ca }";
|
||||
$texVC = new TexVC();
|
||||
$options = [ "usemhchem" => true, "usemhchemtexified" => true ];
|
||||
$warnings = [];
|
||||
$res = $texVC->check( $input, $options, $warnings, true );
|
||||
$mml = $res['input']->renderMML();
|
||||
$this->assertStringContainsString( '<mi', $mml );
|
||||
$this->assertStringContainsString( $result . '</mi>', $mml );
|
||||
$this->assertStringContainsString( '<mo>∼</mo>', $mml );
|
||||
}
|
||||
|
||||
public function testHarpoonsLeftRight() {
|
||||
$input = "A \\longLeftrightharpoons L";
|
||||
$texVC = new TexVC();
|
||||
|
|
Loading…
Reference in a new issue