Add default display options

In some cases for example if the vagrant role
mobilefrontend is enabled the stylesheets are not
processed on mobile devices.
Without a default setting for the display attribute
all elements are displayed at the same time.

Change-Id: Ic0e95effaf0b413ec4c5878e1cfd5c269daa44c3
This commit is contained in:
Frédéric Wang 2014-07-25 07:33:18 +02:00 committed by Physikerwelt
parent bc519c22f4
commit f590974c25
2 changed files with 9 additions and 9 deletions

View File

@ -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( '/<math/', '<math display="block"', $mml );
}
$output .= Xml::tags( $element, array( 'class' => $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 );

View File

@ -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; }
}