diff --git a/src/TexVC/ParserUtil.php b/src/TexVC/ParserUtil.php index 5836384d0..9119ebaa1 100644 --- a/src/TexVC/ParserUtil.php +++ b/src/TexVC/ParserUtil.php @@ -35,6 +35,7 @@ class ParserUtil { $optionsBase = [ 'usemathrm' => false, 'usemhchem' => false, + 'usemhchemtexified' => false, 'oldtexvc' => false, 'oldmhchem' => false, 'debug' => false, diff --git a/src/TexVC/TexVC.php b/src/TexVC/TexVC.php index 6bdf0dd5b..2c6c32b8a 100644 --- a/src/TexVC/TexVC.php +++ b/src/TexVC/TexVC.php @@ -73,7 +73,7 @@ class TexVC { ]; if ( $options['report_required'] ) { - $pkgs = [ 'ams', 'cancel', 'color', 'euro', 'teubner', 'mhchem', 'mathoid' ]; + $pkgs = [ 'ams', 'cancel', 'color', 'euro', 'teubner', 'mhchem', 'mathoid', 'mhchemtexified' ]; foreach ( $pkgs as $pkg ) { $pkg .= '_required'; @@ -92,6 +92,16 @@ class TexVC { ]; } } + if ( !$options['usemhchemtexified'] ) { + if ( $result['mhchemtexified_required'] ?? + $input->containsFunc( $this->tu->getBaseElements()['mhchemtexified_required'] ) + ) { + return [ + 'status' => 'C', + 'details' => 'virtual mhchemtexified package required.' + ]; + } + } return $result; } catch ( Exception $ex ) { if ( $ex instanceof SyntaxError && !$options['oldtexvc'] diff --git a/src/TexVC/texutil.json b/src/TexVC/texutil.json index 05b0e3a79..0ce6072d1 100644 --- a/src/TexVC/texutil.json +++ b/src/TexVC/texutil.json @@ -1386,18 +1386,34 @@ "\\log": { "latex_function_names": true }, + "\\longLeftrightharpoons": { + "mhchemtexified_required": true, + "nullary_macro": true + }, + "\\longRightleftharpoons": { + "mhchemtexified_required": true, + "nullary_macro": true + }, "\\longleftarrow": { "nullary_macro": true }, "\\longleftrightarrow": { "nullary_macro": true }, + "\\longleftrightarrows": { + "mhchemtexified_required": true, + "nullary_macro": true + }, "\\longmapsto": { "nullary_macro": true }, "\\longrightarrow": { "nullary_macro": true }, + "\\longrightleftharpoons": { + "mhchemtexified_required": true, + "nullary_macro": true + }, "\\looparrowleft": { "ams_required": true, "nullary_macro": true @@ -2320,6 +2336,10 @@ "ams_required": true, "nullary_macro": true }, + "\\tripledash": { + "mhchemtexified_required": true, + "nullary_macro": true + }, "\\twoheadleftarrow": { "ams_required": true, "other_delimiters1": true diff --git a/tests/phpunit/unit/TexVC/ApiTest.php b/tests/phpunit/unit/TexVC/ApiTest.php index 2b644e13e..ceaf844de 100644 --- a/tests/phpunit/unit/TexVC/ApiTest.php +++ b/tests/phpunit/unit/TexVC/ApiTest.php @@ -238,4 +238,16 @@ class ApiTest extends MediaWikiUnitTestCase { [ 'usemhchem' => true, 'oldmhchem' => true ] ); $this->assertEquals( ']_{x}^{2}', $result['output'] ); } + + public function mhchemtexifiedTest() { + $result = $this->texVC->check( '\\longleftrightarrows', + [ 'usemhchemtexified' => true ] ); + $this->assertEquals( '\\longleftrightarrows', $result['output'] ); + } + + public function mhchemtexifiedTestFail() { + $result = $this->texVC->check( '\\longleftrightarrows' ); + $this->assertEquals( 'C', $result['status'] ); + $this->assertFalse( $result['success'] ); + } } diff --git a/tests/phpunit/unit/TexVC/MMLGenerationTexUtilTest.php b/tests/phpunit/unit/TexVC/MMLGenerationTexUtilTest.php index 516937862..1af24e850 100644 --- a/tests/phpunit/unit/TexVC/MMLGenerationTexUtilTest.php +++ b/tests/phpunit/unit/TexVC/MMLGenerationTexUtilTest.php @@ -27,8 +27,8 @@ class MMLGenerationTexUtilTest extends MediaWikiUnitTestCase { private static $SIMILARITYTRESH = 0.7; private static $SKIPXMLVALIDATION = true; private static $APPLYFILTER = false; - private static $APPLYCATEGORYFILTER = false; - private static $FILTEREDCATEGORIES = [ "fun_ar1" ]; + private static $APPLYCATEGORYFILTER = true; + private static $SKIPPEDCATEGORIES = [ "mhchemtexified_required" ]; private static $FILTERSTART = 15; private static $FILTERLENGTH = 1; @@ -39,7 +39,7 @@ class MMLGenerationTexUtilTest extends MediaWikiUnitTestCase { /** @var bool export the updated TexUtil-Tex to "./ExportedTexUtilKeys.json" */ private static $EXPORT_KEYS = false; - private static $SKIPPEDINDICES = [ 15,33, 90, 383,554 ]; + private static $SKIPPEDINDICES = [ 15, 33, 90, 383, 554 ]; /** * @dataProvider provideTestCases @@ -215,7 +215,7 @@ class MMLGenerationTexUtilTest extends MediaWikiUnitTestCase { $overAllCtr = 0; $finalCases = []; foreach ( $groups as $category => $group ) { - if ( self::$APPLYCATEGORYFILTER && !in_array( $category, self::$FILTEREDCATEGORIES, true ) ) { + if ( self::$APPLYCATEGORYFILTER && !in_array( $category, self::$SKIPPEDCATEGORIES, true ) ) { continue; } $indexCtr = 0; diff --git a/tests/phpunit/unit/TexVC/TexUtilTest.php b/tests/phpunit/unit/TexVC/TexUtilTest.php index 58a9d571f..42a8acbe6 100644 --- a/tests/phpunit/unit/TexVC/TexUtilTest.php +++ b/tests/phpunit/unit/TexVC/TexUtilTest.php @@ -61,6 +61,7 @@ class TexUtilTest extends MediaWikiUnitTestCase { 'mhchem_macro_2pc', 'mhchem_macro_2pu', 'mhchem_required', + 'mhchemtexified_required', 'mhchem_single_macro', 'nullary_macro', 'nullary_macro_in_mbox',