diff --git a/src/WikiTexVC/MMLmappings/BaseMethods.php b/src/WikiTexVC/MMLmappings/BaseMethods.php index 8bf289bb7..0eafb6ecb 100644 --- a/src/WikiTexVC/MMLmappings/BaseMethods.php +++ b/src/WikiTexVC/MMLmappings/BaseMethods.php @@ -131,6 +131,9 @@ class BaseMethods { // see: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/961213 $mspace = new MMLmspace( "", [ "width" => "0.5em" ] ); return $mspace->getEmpty(); + case '/': + $mmlMo = new MMLmo( '', [ 'lspace' => '0', 'rspace' => '0' ] ); + return $mmlMo->encapsulateRaw( $input ); } return $input; } diff --git a/src/WikiTexVC/MMLmappings/OperatorDictionary.php b/src/WikiTexVC/MMLmappings/OperatorDictionary.php index 63d416a6c..9597bd3c7 100644 --- a/src/WikiTexVC/MMLmappings/OperatorDictionary.php +++ b/src/WikiTexVC/MMLmappings/OperatorDictionary.php @@ -35,7 +35,7 @@ class OperatorDictionary { '->' => [ " exports.MO.BIN5" ], '.' => [ " [0, 3], MmlNode_js_1.TEXCLASS.PUNCT\"], { separator=> [ true }]" ], ':' => [ " [1, 2], MmlNode_js_1.TEXCLASS.REL\"], null]" ], - '/' => [ " exports.MO.ORD11" ], + '/' => [ " exports.MO.ORD11", true ], '//' => [ " OPDEF(1\"], 1)" ], '/=' => [ " exports.MO.BIN4" ], '=>' => [ " [1, 2], MmlNode_js_1.TEXCLASS.REL\"], null]" ], diff --git a/tests/phpunit/unit/WikiTexVC/Nodes/LiteralTest.php b/tests/phpunit/unit/WikiTexVC/Nodes/LiteralTest.php index 25b9e77ac..9dd963f1a 100644 --- a/tests/phpunit/unit/WikiTexVC/Nodes/LiteralTest.php +++ b/tests/phpunit/unit/WikiTexVC/Nodes/LiteralTest.php @@ -124,4 +124,13 @@ class LiteralTest extends MediaWikiUnitTestCase { 'exclamation mark should render as special operator.' ); } + public function testDivide() { + $n = new Literal( '/' ); + $real = $n->renderMML(); + $this->assertStringContainsString( '/', $real, + 'divide should render as special operator.' ); + $this->assertStringContainsString( 'lspace="0" rspace="0"', $real, + 'divide should have no spacing.' ); + } + }