Fix spaces defined by tilde and backslash

* MMLFullCoverageTest case: 261

Bug: T327391
Change-Id: I99def9fe47ceb4471826e96e25562c070c0f1303
This commit is contained in:
Stegmujo 2023-03-16 15:40:49 +00:00
parent 6e0181335f
commit 95816376c1
No known key found for this signature in database
GPG key ID: FEFA628F883FAE29
5 changed files with 35 additions and 19 deletions

View file

@ -18,21 +18,21 @@ class BaseMappings {
// Macro Map 'special'
private const SPECIAL = [
'{' => 'Open',
'}' => 'Close',
'~' => 'Tilde',
'^' => 'Superscript',
'_' => 'Subscript',
' ' => 'Space',
'\t' => 'Space',
'\r' => 'Space',
'\n' => 'Space',
'\\' => 'Prime',
'%' => 'Comment',
'&' => 'Entry',
'#' => 'Hash',
'\u00A0' => 'Space',
'\u2019' => 'Prime'
'{' => 'open',
'}' => 'close',
'~' => [ 'tilde',true ],
'^' => 'superscript',
'_' => 'subscript',
' ' => 'space',
'\t' => 'space',
'\r' => 'space',
'\n' => 'space',
'\\' => 'prime',
'%' => 'comment',
'&' => 'entry',
'#' => 'hash',
'\u00A0' => 'space',
'\u2019' => 'prime'
];
private const MATHCHAR0MI = [
@ -831,7 +831,12 @@ class BaseMappings {
}
public static function getSpecialByKey( $key ) {
return MMLutil::getMappingByKeySimple( $key, self::SPECIAL );
$ret = MMLutil::getMappingByKeySimple( $key, self::SPECIAL );
// Only activated elements get found in this mapping currently.
if ( is_array( $ret ) && count( $ret ) >= 2 && $ret[1] ) {
return $ret;
}
return null;
}
public static function getCancelByKey( $key ) {

View file

@ -47,7 +47,10 @@ class BaseMethods {
if ( $resFct == null ) {
$resFct = BaseMappings::getCustomByKey( $input );
if ( $resFct == null ) {
$resFct = BaseMappings::getMhChemByKey( $input );
$resFct = BaseMappings::getSpecialByKey( $input );
if ( $resFct == null ) {
$resFct = BaseMappings::getMhChemByKey( $input );
}
}
}
}
@ -130,7 +133,9 @@ class BaseMethods {
case ">":
$mmlMo = new MMLmo();
return $mmlMo->encapsulate( ">" );
case "\\":
$mmlMtext = new MMLmtext();
return $mmlMtext->encapsulate( " " );
}
return $input;
}

View file

@ -949,6 +949,11 @@ class BaseParsing {
);
}
public static function tilde( $node, $passedArgs, $operatorContent, $name ) {
$mText = new MMLmtext( "", $passedArgs );
return $mText->encapsulate( " " );
}
public static function xArrow( $node, $passedArgs, $operatorContent, $name, $chr = null, $l = null, $r = null ) {
$defWidth = "+" . MMLutil::round2em( ( $l + $r ) / 18 );
$defLspace = MMLutil::round2em( $l / 18 );

View file

@ -48,7 +48,7 @@ class OperatorDictionary {
'>=' => [ " exports.MO.BIN5" ],
'?' => [ " [1, 1], MmlNode_js_1.TEXCLASS.CLOSE], null]" ],
'@' => [ " exports.MO.ORD11" ],
'\\' => [ " exports.MO.ORD" ],
'\\' => [ " exports.MO.ORD", true ],
'^' => [ " exports.MO.ORD11" ],
'_' => [ " exports.MO.ORD11" ],
'|' => [ " [2, 2], MmlNode_js_1.TEXCLASS.ORD]," .

View file

@ -94,6 +94,7 @@ class Literal extends TexNode {
// No mi, if literal is from HBox
return $input;
}
// If falling through all sieves just create an MI element
$mi = new MMLmi( "", $arguments );
return $mi->encapsulateRaw( $input ); // $this->arg