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' // Macro Map 'special'
private const SPECIAL = [ private const SPECIAL = [
'{' => 'Open', '{' => 'open',
'}' => 'Close', '}' => 'close',
'~' => 'Tilde', '~' => [ 'tilde',true ],
'^' => 'Superscript', '^' => 'superscript',
'_' => 'Subscript', '_' => 'subscript',
' ' => 'Space', ' ' => 'space',
'\t' => 'Space', '\t' => 'space',
'\r' => 'Space', '\r' => 'space',
'\n' => 'Space', '\n' => 'space',
'\\' => 'Prime', '\\' => 'prime',
'%' => 'Comment', '%' => 'comment',
'&' => 'Entry', '&' => 'entry',
'#' => 'Hash', '#' => 'hash',
'\u00A0' => 'Space', '\u00A0' => 'space',
'\u2019' => 'Prime' '\u2019' => 'prime'
]; ];
private const MATHCHAR0MI = [ private const MATHCHAR0MI = [
@ -831,7 +831,12 @@ class BaseMappings {
} }
public static function getSpecialByKey( $key ) { 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 ) { public static function getCancelByKey( $key ) {

View file

@ -46,6 +46,8 @@ class BaseMethods {
$resFct = BaseMappings::getcancelByKey( $input ); $resFct = BaseMappings::getcancelByKey( $input );
if ( $resFct == null ) { if ( $resFct == null ) {
$resFct = BaseMappings::getCustomByKey( $input ); $resFct = BaseMappings::getCustomByKey( $input );
if ( $resFct == null ) {
$resFct = BaseMappings::getSpecialByKey( $input );
if ( $resFct == null ) { if ( $resFct == null ) {
$resFct = BaseMappings::getMhChemByKey( $input ); $resFct = BaseMappings::getMhChemByKey( $input );
} }
@ -53,6 +55,7 @@ class BaseMethods {
} }
} }
} }
}
if ( $resFct == null ) { if ( $resFct == null ) {
return null; return null;
} }
@ -130,7 +133,9 @@ class BaseMethods {
case ">": case ">":
$mmlMo = new MMLmo(); $mmlMo = new MMLmo();
return $mmlMo->encapsulate( ">" ); return $mmlMo->encapsulate( ">" );
case "\\":
$mmlMtext = new MMLmtext();
return $mmlMtext->encapsulate( " " );
} }
return $input; 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 ) { public static function xArrow( $node, $passedArgs, $operatorContent, $name, $chr = null, $l = null, $r = null ) {
$defWidth = "+" . MMLutil::round2em( ( $l + $r ) / 18 ); $defWidth = "+" . MMLutil::round2em( ( $l + $r ) / 18 );
$defLspace = MMLutil::round2em( $l / 18 ); $defLspace = MMLutil::round2em( $l / 18 );

View file

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

View file

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