mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 23:25:02 +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 );
|
return $this->parseOperatorDict( $node, $passedArgs, $operatorContent, $input, false );
|
||||||
}
|
}
|
||||||
// Atm just do simple parsing for elements in operator dictionary
|
// Atm just do simple parsing for elements in operator dictionary
|
||||||
$mmlMo = new MMLmo();
|
$mmlMo = new MMLmo( '', $passedArgs );
|
||||||
return $mmlMo->encapsulateRaw( $input );
|
return $mmlMo->encapsulateRaw( $input );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,10 @@ class Literal extends TexNode {
|
||||||
|
|
||||||
// Sieve for Operators
|
// Sieve for Operators
|
||||||
$bm = new BaseMethods();
|
$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 ) {
|
if ( $ret ) {
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +112,7 @@ class Literal extends TexNode {
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
// Sieve for Delimiters
|
// Sieve for Delimiters
|
||||||
$ret = $bm->checkAndParseDelimiter( $input, $this, $arguments, $operatorContent );
|
$ret = $bm->checkAndParseDelimiter( $input, $this, $noStretchArgs, $operatorContent );
|
||||||
if ( $ret ) {
|
if ( $ret ) {
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ final class MhchemBasicMMLTest extends MediaWikiUnitTestCase {
|
||||||
$mml = $res['input']->renderMML();
|
$mml = $res['input']->renderMML();
|
||||||
$this->assertStringContainsString( '<mi', $mml );
|
$this->assertStringContainsString( '<mi', $mml );
|
||||||
$this->assertStringContainsString( $result . '</mi>', $mml );
|
$this->assertStringContainsString( $result . '</mi>', $mml );
|
||||||
$this->assertStringContainsString( '<mo>∼</mo>', $mml );
|
$this->assertStringContainsString( '∼</mo>', $mml );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHarpoonsLeftRight() {
|
public function testHarpoonsLeftRight() {
|
||||||
|
@ -77,7 +77,7 @@ final class MhchemBasicMMLTest extends MediaWikiUnitTestCase {
|
||||||
$warnings = [];
|
$warnings = [];
|
||||||
$res = $texVC->check( $input, $options, $warnings, true );
|
$res = $texVC->check( $input, $options, $warnings, true );
|
||||||
$mml = $res['input']->renderMML();
|
$mml = $res['input']->renderMML();
|
||||||
$this->assertStringContainsString( '<mo>−</mo>', $mml );
|
$this->assertStringContainsString( '−</mo>', $mml );
|
||||||
$this->assertStringContainsString( '⇀', $mml );
|
$this->assertStringContainsString( '⇀', $mml );
|
||||||
$this->assertStringContainsString( '<mpadded height="0" depth="0">', $mml );
|
$this->assertStringContainsString( '<mpadded height="0" depth="0">', $mml );
|
||||||
$this->assertStringContainsString( '<mspace ', $mml );
|
$this->assertStringContainsString( '<mspace ', $mml );
|
||||||
|
@ -212,7 +212,7 @@ final class MhchemBasicMMLTest extends MediaWikiUnitTestCase {
|
||||||
$warnings = [];
|
$warnings = [];
|
||||||
$checkRes = $texVC->check( $input, [ "usemhchem" => true, "usemhchemtexified" => true ],
|
$checkRes = $texVC->check( $input, [ "usemhchem" => true, "usemhchemtexified" => true ],
|
||||||
$warnings, true );
|
$warnings, true );
|
||||||
$this->assertStringContainsString( '<mpadded width="0"><mo>−</mo></mpadded>',
|
$this->assertStringContainsString( '−</mo></mpadded>',
|
||||||
$checkRes["input"]->renderMML() );
|
$checkRes["input"]->renderMML() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,4 +106,16 @@ class LiteralTest extends MediaWikiUnitTestCase {
|
||||||
'colon should render as special operator.' );
|
'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