| 1 |
<?php |
| 2 |
|
| 3 |
declare( strict_types = 1 ); |
| 4 |
|
| 5 |
namespace MediaWiki\Extension\Math\WikiTexVC\Nodes; |
| 6 |
|
| 7 |
use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmrow; |
| 8 |
use MediaWiki\Extension\Math\WikiTexVC\MMLnodes\MMLmtext; |
| 9 |
|
| 10 |
class Box extends TexNode { |
| 11 |
|
| 12 |
|
| 13 |
private $fname; |
| 14 |
|
| 15 |
private $arg; |
| 16 |
|
| 17 |
public function __construct( string $fname, string $arg ) { |
| 18 |
parent::__construct( $fname, $arg ); |
| 19 |
$this->fname = $fname; |
| 20 |
$this->arg = $arg; |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public function getFname(): string { |
| 27 |
return $this->fname; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public function getArg(): string { |
| 34 |
return $this->arg; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
public function inCurlies() { |
| 39 |
return $this->render(); |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
public function render() { |
| 44 |
return '{' . $this->fname . '{' . $this->arg . '}}'; |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
public function renderMML( $arguments = [], &$state = [] ) { |
| 49 |
$mrow = new MMLmrow(); |
| 50 |
$mtext = new MMLmtext(); |
| 51 |
$arg = $this->getArg(); |
| 52 |
|
| 53 |
if ( strlen( $arg ) >= 1 ) { |
| 54 |
|
| 55 |
if ( substr( $arg, -1, 1 ) === " " ) { |
| 56 |
$arg = rtrim( $arg, " " ) . " "; |
| 57 |
} |
| 58 |
if ( substr( $arg, 0, 1 ) == " " ) { |
| 59 |
$arg = " " . ltrim( $arg, " " ); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
return $mrow->encapsulateRaw( |
| 64 |
$mtext->encapsulateRaw( $arg ) |
| 65 |
); |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
public function extractIdentifiers( $args = null ) { |
| 70 |
return []; |
| 71 |
} |
| 72 |
|
| 73 |
} |