| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
namespace MediaWiki\Extension\Math; |
| 14 |
|
| 15 |
use LogicException; |
| 16 |
use MediaWiki\Html\Html; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
class MathSource extends MathRenderer { |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public function __construct( $tex = '', $params = [] ) { |
| 32 |
parent::__construct( $tex, $params ); |
| 33 |
$this->setMode( MathConfig::MODE_SOURCE ); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public function getHtmlOutput( bool $svg = true ): string { |
| 43 |
|
| 44 |
|
| 45 |
if ( $this->getMathStyle() == 'display' ) { |
| 46 |
$class = 'mwe-math-fallback-source-display'; |
| 47 |
} else { |
| 48 |
$class = 'mwe-math-fallback-source-inline'; |
| 49 |
} |
| 50 |
return Html::element( 'span', |
| 51 |
$this->getAttributes( |
| 52 |
'span', |
| 53 |
[ |
| 54 |
|
| 55 |
|
| 56 |
'class' => $class . ' tex', |
| 57 |
'dir' => 'ltr' |
| 58 |
] |
| 59 |
), |
| 60 |
'$ ' . str_replace( "\n", " ", $this->getTex() ) . ' $' |
| 61 |
); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
protected function getMathTableName() { |
| 69 |
throw new LogicException( 'in math source mode no database caching should happen' ); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
public function render() { |
| 77 |
|
| 78 |
$this->changed = false; |
| 79 |
return true; |
| 80 |
} |
| 81 |
} |