Fix parsing functions for MMLGenerationTexVCUtilTest

* for "oint","ointctrclockwise", "varointclockwise."
* some ignored attributes added to similarity algorithm

Bug: T327392
Change-Id: Id4cf720bb2d2c8aeb524c2303bdf0d4be3547404
This commit is contained in:
Stegmujo 2023-02-03 15:08:00 +00:00 committed by Physikerwelt
parent 5eba9b74a0
commit dbf15a72c6
5 changed files with 41 additions and 10 deletions

View file

@ -129,7 +129,6 @@ class BaseMappings {
"movesupsub" => true ] ],
"bigodot" => [ '\u2A00', [ "texClass" => TexClass::OP,
"movesupsub" => true ] ],
"oint" => [ '\u222E', [ "texClass" => TexClass::OP ] ],
"bigsqcup" => [ '\u2A06', [ "texClass" => TexClass::OP,
"movesupsub" => true ] ],
"smallint" => [ '\u222B', [ "largeop" => false ] ],
@ -748,11 +747,11 @@ class BaseMappings {
// These are some mappings which are created customly for this
private const CUSTOM = [
"boldsymbol" => [ 'boldsymbol','' ], // see boldsymbolConfiguration.js
"oint" => [ 'oint', '\u222E', [ "texClass" => TexClass::OP ] ],
"oiint" => [ 'oint', '\u222F', [ "texClass" => TexClass::OP ] ],
"oiiint" => [ 'oint', '\u2230', [ "texClass" => TexClass::OP ] ],
"ointctrclockwise" => [ 'oint', '?', [ "texClass" => TexClass::OP ] ],
// \varointclockwise
"varointclockwise" => [ 'oint', '?', [ "texClass" => TexClass::OP ] ],
"ointctrclockwise" => [ 'oint', '\u2233', [ "texClass" => TexClass::OP ] ],
"varointclockwise" => [ 'oint', '\u2232', [ "texClass" => TexClass::OP ] ],
"P" => [ 'oint', '?', [ "texClass" => TexClass::OP ] ], // not correct but same mapping
'textvisiblespace' => [ 'Insert', '\u2423' ], // From TextCompMappings.js (only makro it seems)
];

View file

@ -63,7 +63,6 @@ class BaseMethods {
// Passing resolved function as param without first id
if ( count( $resFct ) > 1 ) {
$shifted = array_shift( $resFct );
return BaseParsing::{$shifted}( $node, $passedArgs, $operatorContent, $input, ...$resFct );
} else {
return BaseParsing::{$resFct[0]}( $node, $passedArgs, $operatorContent, $input );

View file

@ -3,6 +3,7 @@ namespace MediaWiki\Extension\Math\TexVC\MMLmappings;
use IntlChar;
use MediaWiki\Extension\Math\TexVC\MMLmappings\TexConstants\Misc;
use MediaWiki\Extension\Math\TexVC\MMLmappings\TexConstants\Sizes;
use MediaWiki\Extension\Math\TexVC\MMLmappings\TexConstants\Tag;
use MediaWiki\Extension\Math\TexVC\MMLmappings\TexConstants\TexClass;
use MediaWiki\Extension\Math\TexVC\MMLmappings\TexConstants\Variants;
@ -404,7 +405,7 @@ class BaseParsing {
);
return $mmlRow->encapsulateRaw( $mmlRowInner->encapsulateRaw( $inner ) );
case "bmod":
$mo = new MMLmo( "", [ "lspace" => "thickmathspace", "rspace" => "thickmathspace" ] );
$mo = new MMLmo( "", [ "lspace" => Sizes::THICKMATHSPACE, "rspace" => Sizes::THICKMATHSPACE ] );
$mmlRow = new MMLmrow( TexClass::ORD );
$mstyle = new MMLmstyle( "", [ "scriptlevel" => "0" ] );
$mspace = new MMLmspace( "", [ "width" => "0.167em" ] );
@ -551,14 +552,26 @@ class BaseParsing {
}
public static function oint( $node, $passedArgs, $operatorContent,
$name, $uc = null, $smth1 = null, $smth2 = null ) {
$name, $uc = null, $attributes = null, $smth2 = null ) {
// This is a custom mapping not in js.
$mmlText = new MMLmtext( "", [ "mathcolor" => "red" ] );
$mmlText = new MMLmtext( "", $attributes );
$mrow = new MMLmrow();
$mStyle = new MMLmstyle( "", [ "mathsize" => "2.07em" ] );
switch ( $name ) {
case "oiiint":
case "oint":
$mo = new MMLmo();
return $mrow->encapsulateRaw( $mStyle->encapsulateRaw(
$mo->encapsulateRaw( MMLutil::uc2xNotation( $uc ) ) ) );
case "oiint":
case "oiiint":
case "ointctrclockwise":
case "varointclockwise":
$mSpace = new MMLmspace( "", [ "width" => Sizes::THINMATHSPACE ] );
return $mrow->encapsulateRaw( $mStyle->encapsulateRaw(
$mmlText->encapsulateRaw( MMLutil::uc2xNotation( $uc ) )
. $mSpace->getEmpty() ) );
case "P":
return $mmlText->encapsulate( "\\" . $name );
default:

View file

@ -0,0 +1,19 @@
<?php
namespace MediaWiki\Extension\Math\TexVC\MMLmappings\TexConstants;
class Sizes {
public const VERYVERYTHINMATHSPACE = 1 / 18 . "em";
public const VERYTHINMATHSPACE = 2 / 18 . "em";
public const THINMATHSPACE = 3 / 18 . "em";
public const MEDIUMMATHSPACE = 4 / 18 . "em";
public const THICKMATHSPACE = 5 / 18 . "em";
public const VERYTHICKMATHSPACE = 6 / 18 . "em";
public const VERYVERYTHICKMATHSPACE = 7 / 18 . "em";
public const NEGATIVEVERYVERYTHINMATHSPACE = -1 / 18 . "em";
public const NEGATIVEVERYTHINMATHSPACE = -2 / 18 . "em";
public const NEGATIVETHINMATHSPACE = -3 / 18 . "em";
public const NEGATIVEMEDIUMMATHSPACE = -4 / 18 . "em";
public const NEGATIVETHICKMATHSPACE = -5 / 18 . "em";
public const NEGATIVEVERYTHICKMATHSPACE = -6 / 18 . "em";
public const NEGATIVEVERYVERYTHICKMATHSPACE = -7 / 18 . "em";
}

View file

@ -39,7 +39,8 @@ class MMLComparator {
"math" => [ "alttext", "display" ],
"mi" => [ "class", "data-mjx-variant", "mathvariant", "data-mjx-texclass", "data-mjx-alternate" ],
"mo" => [ "data-mjx-pseudoscript", "stretchy", "fence", "data-mjx-texclass", "texClass", "class",
"data-mjx-alternate", "form", "accent" ]
"data-mjx-alternate", "form", "accent" ],
"mtext" => [ "texClass" ]
];
/**