mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-21 11:52:40 +00:00
41 lines
1,008 B
PHP
41 lines
1,008 B
PHP
|
<?php
|
||
|
/**
|
||
|
* MediaWiki math extension
|
||
|
*
|
||
|
* @copyright 2002-2023 various MediaWiki contributors
|
||
|
* @license GPL-2.0-or-later
|
||
|
*/
|
||
|
|
||
|
namespace MediaWiki\Extension\Math;
|
||
|
|
||
|
use MediaWiki\Extension\Math\InputCheck\LocalChecker;
|
||
|
use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmath;
|
||
|
use StatusValue;
|
||
|
|
||
|
/**
|
||
|
* Converts LaTeX to MathML using PHP
|
||
|
*/
|
||
|
class MathNativeMML extends MathMathML {
|
||
|
private LocalChecker $checker;
|
||
|
|
||
|
public function __construct( $tex = '', $params = [] ) {
|
||
|
parent::__construct( $tex, $params );
|
||
|
$this->setMode( MathConfig::MODE_NATIVE_MML );
|
||
|
$this->setPurge();
|
||
|
}
|
||
|
|
||
|
protected function doRender(): StatusValue {
|
||
|
$presentation = $this->getChecker()->getParseTree()->renderMML();
|
||
|
$root = new MMLmath();
|
||
|
$this->setMathml( $root->encapsulateRaw( $presentation ) );
|
||
|
return StatusValue::newGood();
|
||
|
}
|
||
|
|
||
|
protected function getChecker(): LocalChecker {
|
||
|
$this->checker ??= Math::getCheckerFactory()
|
||
|
->newLocalChecker( $this->tex, $this->getInputType() );
|
||
|
return $this->checker;
|
||
|
}
|
||
|
|
||
|
}
|