mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-28 01:10:09 +00:00
Merge "Activate chem and inline-tex type input in LocalChecker"
This commit is contained in:
commit
ded8f70772
|
@ -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