diff --git a/MathMathML.php b/MathMathML.php index 886eb3e..23d98c7 100644 --- a/MathMathML.php +++ b/MathMathML.php @@ -342,11 +342,10 @@ class MathMathML extends MathRenderer { */ public function correctSvgStyle( $svg, &$style ) { if ( preg_match( '/style="([^"]*)"/', $svg, $styles ) ) { - $style = $styles[1]; + $style .= " ".$styles[1]; // merge styles if ( $this->getMathStyle() === MW_MATHSTYLE_DISPLAY ) { // TODO: Improve style cleaning $style = preg_replace( '/margin\-(left|right)\:\s*\d+(\%|in|cm|mm|em|ex|pt|pc|px)\;/', '', $style ); - $style .= 'display: block; margin-left: auto; margin-right: auto;'; } } } @@ -368,10 +367,11 @@ class MathMathML extends MathRenderer { $attribs = array(); if ( $classOverride === false ) { // $class = '' suppresses class attribute $class = $this->getClassName( true, $png ); + $style = $png ? '' : 'display: none;'; } else { $class = $classOverride; + $style = ''; } - $style = ''; if ( !$png ) { $this->correctSvgStyle( $this->getSvg(), $style ); } @@ -431,7 +431,7 @@ class MathMathML extends MathRenderer { if ( $this->getMathStyle() == MW_MATHSTYLE_DISPLAY ) { $mml = preg_replace( '/ $this->getClassName() ), $mml ); + $output .= Xml::tags( $element, array( 'class' => $this->getClassName(), 'style' => 'display: none;' ), $mml ); $output .= $this->getFallbackImage( $this->getMode() ) . "\n"; $output .= $this->getFallbackImage( MW_MATH_PNG ) . "\n"; $output .= HTML::closeElement( $element ); diff --git a/modules/ext.math.css b/modules/ext.math.css index 63866f5..dc3abde 100644 --- a/modules/ext.math.css +++ b/modules/ext.math.css @@ -40,16 +40,16 @@ img.mwe-math-fallback-png-display { display: block; } /* For all browsers but IE < 9, hide the PNG fallback and show the SVG instead. We override the default style for PNG and SVG above */ -:root * > img.mwe-math-fallback-svg-inline { display: inline; } -:root * > img.mwe-math-fallback-svg-display { display: block; } +:root * > img.mwe-math-fallback-svg-inline { display: inline !important; } +:root * > img.mwe-math-fallback-svg-display { display: block !important; } :root * > img.mwe-math-fallback-svg-inline + img.mwe-math-fallback-png-inline, :root * > img.mwe-math-fallback-svg-display + img.mwe-math-fallback-png-display { display: none; } @-moz-document url-prefix() { /* For Gecko browsers, hide the SVG fallback and show the MathML instead. We override the style for SVG and MathML above */ - .mwe-math-mathml-inline { display: inline; } - .mwe-math-mathml-display { display: block; } + .mwe-math-mathml-inline { display: inline !important; } + .mwe-math-mathml-display { display: block !important; } :root * > .mwe-math-mathml-inline + img.mwe-math-fallback-svg-inline, - :root * > .mwe-math-mathml-display + img.mwe-math-fallback-svg-display { display: none; } + :root * > .mwe-math-mathml-display + img.mwe-math-fallback-svg-display { display: none !important; } }