Debian Codegraph @

extensions/Math/src/WikiTexVC/Nodes/ChemWord.php

raw symbols SCIP
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 ChemWord extends TexNode {
11
12 /** @var TexNode */
13 public $left;
14 /** @var TexNode */
15 public $right;
16
17 public function __construct( TexNode $left, TexNode $right ) {
18 parent::__construct( $left, $right );
19 $this->left = $left;
20 $this->right = $right;
21 }
22
23 /**
24 * @return TexNode
25 */
26 public function getLeft(): TexNode {
27 return $this->left;
28 }
29
30 /**
31 * @return TexNode
32 */
33 public function getRight(): TexNode {
34 return $this->right;
35 }
36
37 /** @inheritDoc */
38 public function render() {
39 return $this->left->render() . $this->right->render();
40 }
41
42 /** @inheritDoc */
43 public function renderMML( $arguments = [], &$state = [] ) {
44 $mmlMrow = new MMLmrow();
45 $mtextLeft = new MMLmtext( "", [ "mathcolor" => "red" ] );
46 $mtextRight = new MMLmtext();
47 // If right has empty literal content is resolved as dash
48 $right = $this->getRight()->getArgs()[0] == "" ? "-" : $this->getRight()->renderMML( [],
49 $state );
50 return $mmlMrow->encapsulateRaw( $mmlMrow->encapsulateRaw(
51 $mtextLeft->encapsulateRaw( $this->getLeft()->renderMML( [], $state ) )
52 . $mtextRight->encapsulateRaw( $right ) ) );
53 }
54
55 /** @inheritDoc */
56 public function extractIdentifiers( $args = null ) {
57 return [];
58 }
59
60 }