mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-27 17:01:07 +00:00
Merge "Don't stretch delimiters and operators when used as literals"
This commit is contained in:
commit
0bfd22b57b
|
@ -91,7 +91,7 @@ class BaseMethods {
|
|||
return $this->parseOperatorDict( $node, $passedArgs, $operatorContent, $input, false );
|
||||
}
|
||||
// Atm just do simple parsing for elements in operator dictionary
|
||||
$mmlMo = new MMLmo();
|
||||
$mmlMo = new MMLmo( '', $passedArgs );
|
||||
return $mmlMo->encapsulateRaw( $input );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,10 @@ class Literal extends TexNode {
|
|||
|
||||
// Sieve for Operators
|
||||
$bm = new BaseMethods();
|
||||
$ret = $bm->checkAndParseOperator( $inputP, $this, $arguments, $operatorContent, $state, false );
|
||||
$noStretchArgs = $arguments;
|
||||
// Delimiters and operators should not be stretchy by default when used as literals
|
||||
$noStretchArgs['stretchy'] ??= 'false';
|
||||
$ret = $bm->checkAndParseOperator( $inputP, $this, $noStretchArgs, $operatorContent, $state, false );
|
||||
if ( $ret ) {
|
||||
return $ret;
|
||||
}
|
||||
|
@ -109,7 +112,7 @@ class Literal extends TexNode {
|
|||
return $ret;
|
||||
}
|
||||
// Sieve for Delimiters
|
||||
$ret = $bm->checkAndParseDelimiter( $input, $this, $arguments, $operatorContent );
|
||||
$ret = $bm->checkAndParseDelimiter( $input, $this, $noStretchArgs, $operatorContent );
|
||||
if ( $ret ) {
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ final class MhchemBasicMMLTest extends MediaWikiUnitTestCase {
|
|||
$mml = $res['input']->renderMML();
|
||||
$this->assertStringContainsString( '<mi', $mml );
|
||||
$this->assertStringContainsString( $result . '</mi>', $mml );
|
||||
$this->assertStringContainsString( '<mo>∼</mo>', $mml );
|
||||
$this->assertStringContainsString( '∼</mo>', $mml );
|
||||
}
|
||||
|
||||
public function testHarpoonsLeftRight() {
|
||||
|
@ -77,7 +77,7 @@ final class MhchemBasicMMLTest extends MediaWikiUnitTestCase {
|
|||
$warnings = [];
|
||||
$res = $texVC->check( $input, $options, $warnings, true );
|
||||
$mml = $res['input']->renderMML();
|
||||
$this->assertStringContainsString( '<mo>−</mo>', $mml );
|
||||
$this->assertStringContainsString( '−</mo>', $mml );
|
||||
$this->assertStringContainsString( '⇀', $mml );
|
||||
$this->assertStringContainsString( '<mpadded height="0" depth="0">', $mml );
|
||||
$this->assertStringContainsString( '<mspace ', $mml );
|
||||
|
@ -212,7 +212,7 @@ final class MhchemBasicMMLTest extends MediaWikiUnitTestCase {
|
|||
$warnings = [];
|
||||
$checkRes = $texVC->check( $input, [ "usemhchem" => true, "usemhchemtexified" => true ],
|
||||
$warnings, true );
|
||||
$this->assertStringContainsString( '<mpadded width="0"><mo>−</mo></mpadded>',
|
||||
$this->assertStringContainsString( '−</mo></mpadded>',
|
||||
$checkRes["input"]->renderMML() );
|
||||
}
|
||||
|
||||
|
|
|
@ -106,4 +106,16 @@ class LiteralTest extends MediaWikiUnitTestCase {
|
|||
'colon should render as special operator.' );
|
||||
}
|
||||
|
||||
public function testRangle() {
|
||||
$n = new Literal( '\\rangle' );
|
||||
$this->assertStringContainsString( 'stretchy="false"', $n->renderMML(),
|
||||
'colon should render as special operator.' );
|
||||
}
|
||||
|
||||
public function testVert() {
|
||||
$n = new Literal( '|' );
|
||||
$this->assertStringContainsString( 'stretchy="false"', $n->renderMML(),
|
||||
'| should render as special operator.' );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue