mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-14 19:26:08 +00:00
Fix colors
* some tests for checking colors Bug: T327391 Change-Id: I437f8d72834f3cca7c21f97841ee4da2f1f36ed5
This commit is contained in:
parent
41eddd141b
commit
5de6683c05
|
@ -73,11 +73,6 @@ class Literal extends TexNode {
|
|||
if ( $ret ) {
|
||||
return $ret;
|
||||
}
|
||||
// Sieve for Colors
|
||||
$ret = $bm->checkAndParseColor( $input, $this, $arguments, $operatorContent );
|
||||
if ( $ret ) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// Sieve for Makros
|
||||
$ret = BaseMethods::checkAndParse( $input, $arguments, $operatorContent, $this );
|
||||
|
|
|
@ -5,6 +5,7 @@ declare( strict_types = 1 );
|
|||
namespace MediaWiki\Extension\Math\TexVC\Nodes;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use MediaWiki\Extension\Math\TexVC\MMLmappings\BaseMappings;
|
||||
use MediaWiki\Extension\Math\TexVC\MMLmappings\Util\MMLParsingUtil;
|
||||
use MediaWiki\Extension\Math\TexVC\MMLmappings\Util\MMLutil;
|
||||
use MediaWiki\Extension\Math\TexVC\MMLnodes\MMLmo;
|
||||
|
@ -256,7 +257,8 @@ class TexArray extends TexNode {
|
|||
$displayedColor = $state["colorDefinitions"][$currentColor]["hex"];
|
||||
|
||||
} else {
|
||||
$displayedColor = $currentColor;
|
||||
$resColor = BaseMappings::getColorByKey( $currentColor );
|
||||
$displayedColor = $resColor ? $resColor[0] : $currentColor;
|
||||
}
|
||||
$mmlStyleColor = new MMLmstyle( "", [ "mathcolor" => $displayedColor ] );
|
||||
$ret = $mmlStyleColor->encapsulateRaw( $currentNode->renderMML( $arguments, $state ) );
|
||||
|
|
|
@ -117,6 +117,24 @@ class MMLRenderTest extends MediaWikiUnitTestCase {
|
|||
$this->assertStringContainsString( "movablelimits=\"true\"", $mathMLtexVC );
|
||||
}
|
||||
|
||||
public function testColorGeneration1() {
|
||||
$input = "\\color{Dandelion}{Dandelion}";
|
||||
$mathMLtexVC = $this->generateMML( $input );
|
||||
$this->assertStringContainsString( "#FDBC42", $mathMLtexVC );
|
||||
}
|
||||
|
||||
public function testColorGeneration2() {
|
||||
$input = "\\color{ForestGreen}{ForestGreen}";
|
||||
$mathMLtexVC = $this->generateMML( $input );
|
||||
$this->assertStringContainsString( "#009B55", $mathMLtexVC );
|
||||
}
|
||||
|
||||
public function testColorGeneration3() {
|
||||
$input = "\\color{Rhodamine}{Rhodamine}";
|
||||
$mathMLtexVC = $this->generateMML( $input );
|
||||
$this->assertStringContainsString( "#EF559F", $mathMLtexVC );
|
||||
}
|
||||
|
||||
private function generateMML( $input, $chem = false ) {
|
||||
$texVC = new TexVC();
|
||||
$resultT = $texVC->check( $input, [
|
||||
|
|
Loading…
Reference in a new issue