diff --git a/src/TexVC/Nodes/TexNode.php b/src/TexVC/Nodes/TexNode.php index 54d05ac16..24e1f208d 100644 --- a/src/TexVC/Nodes/TexNode.php +++ b/src/TexVC/Nodes/TexNode.php @@ -120,14 +120,14 @@ class TexNode { // special case #3: \\color, \\pagecolor, \\definecolor $matches = []; - $m = preg_match( '/^(\\\\(color|pagecolor|definecolor))/', $t, $matches ); + $m = preg_match( '/^(\\\\(?:page|define)?color) /', $t, $matches ); if ( $m == 1 ) { return self::match( $target, $matches[1] ); } // special case #4: \\mathbb, \\mathrm $matches = []; - $m = preg_match( '/^(\\\\math..) \{(\\.*)}$/', $t, $matches ); + $m = preg_match( '/^(\\\\math..) \{(\\\\.*)}$/', $t, $matches ); if ( $m == 1 ) { return self::match( $target, $matches[1] ) ?: self::match( $target, $matches[2] ); } diff --git a/tests/phpunit/unit/TexVC/Nodes/TexNodeTest.php b/tests/phpunit/unit/TexVC/Nodes/TexNodeTest.php index 2665b8a3f..031fbd439 100644 --- a/tests/phpunit/unit/TexVC/Nodes/TexNodeTest.php +++ b/tests/phpunit/unit/TexVC/Nodes/TexNodeTest.php @@ -137,21 +137,17 @@ class TexNodeTest extends MediaWikiUnitTestCase { [ '\\mismatch', '\\mbox{\\somefunc}', false ], [ '\\somefunc', '\\mbox {\\somefunc}', false ], [ '\\color', '\\color' ], - // FIXME: This might be to relaxed; maybe add a \b to the regex? - [ '\\color', '\\colorscheme because the rest is ignored' ], + [ '\\color', '\\color the rest is ignored' ], [ '\\pagecolor', '\\pagecolor' ], [ '\\definecolor', '\\definecolor' ], - [ '\\mathbb', '\\mathbb {}' ], + [ '\\mathbb', '\\mathbb {}', false ], [ '\\mathbb', '\\mathbb {A}', false ], [ '\\mathbb', '\\mathbb {foo}', false ], [ '\\mathbb', '\\mathbb{}', false ], - - // FIXME: I believe these don't make sense; mistake in the regex? - [ '\\mathbb', '\\mathbb {.}' ], - [ '\\mathbb', '\\mathbb {..........}' ], - // FIXME: I believe these should both succeed - [ '\\mathbb', '\\mathbb {\\foo}', false ], - [ '\\foo', '\\mathbb {\\foo}', false ], + [ '\\mathbb', '\\mathbb {.}', false ], + [ '\\mathbb', '\\mathbb {..........}', false ], + [ '\\mathbb', '\\mathbb {\\foo}' ], + [ '\\foo', '\\mathbb {\\foo}' ], ]; }