mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-14 19:26:08 +00:00
Merge "Fix spaces not rendering if within mtext"
This commit is contained in:
commit
6e0181335f
|
@ -45,8 +45,20 @@ class Box extends TexNode {
|
|||
public function renderMML( $arguments = [], $state = [] ) {
|
||||
$mrow = new MMLmrow();
|
||||
$mtext = new MMLmtext();
|
||||
$arg = $this->getArg();
|
||||
|
||||
if ( strlen( $arg ) >= 1 ) {
|
||||
// Replace trailing and leading spaces with special space sign
|
||||
if ( substr( $arg, -1, 1 ) === " " ) {
|
||||
$arg = rtrim( $arg, " " ) . " ";
|
||||
}
|
||||
if ( substr( $arg, 0, 1 ) == " " ) {
|
||||
$arg = " " . ltrim( $arg, " " );
|
||||
}
|
||||
}
|
||||
|
||||
return $mrow->encapsulateRaw(
|
||||
$mtext->encapsulateRaw( $this->getArg() )
|
||||
$mtext->encapsulateRaw( $arg )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,4 +57,14 @@ class BoxTest extends MediaWikiUnitTestCase {
|
|||
$box = new Box( '\\hbox', 'a' );
|
||||
$this->assertStringContainsString( '</mtext>', $box->renderMML(), 'Render MathML as text.' );
|
||||
}
|
||||
|
||||
public function testTrailingSpaceBoxMML() {
|
||||
$box = new Box( '\\hbox', 'a ' );
|
||||
$this->assertStringContainsString( ' ', $box->renderMML(), 'Should have trailing rendered space' );
|
||||
}
|
||||
|
||||
public function testPrecedingSpaceBoxMML() {
|
||||
$box = new Box( '\\hbox', ' a' );
|
||||
$this->assertStringContainsString( ' ', $box->renderMML(), 'Should have preceding rendered space' );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue