mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-24 07:34:22 +00:00
Activate chem and inline-tex type input in LocalChecker
Bug: T321262 Change-Id: Ib8e55290cc77cdc07274e7f1dbd27d20db0f3227
This commit is contained in:
parent
551bc174c9
commit
c74ced3716
|
@ -21,13 +21,13 @@ class LocalChecker extends BaseChecker {
|
|||
*/
|
||||
public function __construct( $tex = '', $type = 'tex' ) {
|
||||
parent::__construct( $tex );
|
||||
if ( $type !== 'tex' ) {
|
||||
// this type check will be refactored with the introduction of chem-types:
|
||||
// see: https://phabricator.wikimedia.org/T321262
|
||||
if ( $type === 'tex' || $type === 'chem' || $type === 'inline-tex' ) {
|
||||
$this->texVC = new TexVC();
|
||||
$options = $type === 'chem' ? [ "usemhchem" => true ] : null;
|
||||
$this->result = $this->texVC->check( $tex, $options );
|
||||
} else {
|
||||
throw new InvalidArgumentException( "Non supported type passed to LocalChecker: " . $type );
|
||||
}
|
||||
$this->texVC = new TexVC();
|
||||
$this->result = $this->texVC->check( $tex );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,14 +24,24 @@ class LocalCheckerTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertSame( '\\sin x^{2}', $checker->getValidTex() );
|
||||
}
|
||||
|
||||
public function testValidType() {
|
||||
public function testValidTypeTex() {
|
||||
$checker = new LocalChecker( '\sin x^2', 'tex' );
|
||||
$this->assertTrue( $checker->isValid() );
|
||||
}
|
||||
|
||||
public function testValidTypeChem() {
|
||||
$checker = new LocalChecker( '{\\displaystyle {\\ce {\\cdot OHNO_{2}}}}', 'chem' );
|
||||
$this->assertTrue( $checker->isValid() );
|
||||
}
|
||||
|
||||
public function testValidTypeInline() {
|
||||
$checker = new LocalChecker( '{\\textstyle \\log2 }', 'inline-tex' );
|
||||
$this->assertTrue( $checker->isValid() );
|
||||
}
|
||||
|
||||
public function testInvalidType() {
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
new LocalChecker( '\sin x^2', 'chem' );
|
||||
new LocalChecker( '\sin x^2', 'INVALIDTYPE' );
|
||||
}
|
||||
|
||||
public function testInvalid() {
|
||||
|
|
Loading…
Reference in a new issue