Displaystyle in Mathoid 0.2.5

Beginning from mathoid 0.2.5 displaystyle is the default
option. This property has to be removed as default.

Change-Id: I3c176f4227f32709f6db4014e1e3b435c3c853c4
This commit is contained in:
physikerwelt (Moritz Schubotz) 2014-07-10 16:14:26 +01:00 committed by Physikerwelt
parent f0f2e3898f
commit 5e2c1c5101
2 changed files with 4 additions and 6 deletions

View File

@ -425,13 +425,11 @@ class MathMathML extends MathRenderer {
}
$output = HTML::openElement( $element, $attribs );
// MathML has to be wrapped into a div or span in order to be able to hide it.
// Remove displayStyle attributes set by the MathML converter
// (Beginning from Mathoid 0.2.5 block is the default layout.)
$mml = preg_replace( '/(<math[^>]*)(display|mode)=["\'](inline|block)["\']/', '$1', $this->getMathml() );
if ( $this->getMathStyle() == MW_MATHSTYLE_DISPLAY ) {
// Remove displayStyle attributes set by the MathML converter
$mml = preg_replace( '/(<math[^>]*)(display|mode)=["\'](inline|block)["\']/', '$1', $this->getMathml() );
// and insert the correct value
$mml = preg_replace( '/<math/', '<math display="block"', $mml );
} else {
$mml = $this->getMathml();
}
$output .= Xml::tags( $element, array( 'class' => $this->getClassName() ), $mml );
$output .= $this->getFallbackImage( $this->getMode() ) . "\n";

View File

@ -43,7 +43,7 @@ class MathLaTeXMLTest extends MediaWikiTestCase {
$this->setMwGlobals( 'wgMathValidModes', array( MW_MATH_LATEXML ) );
$renderer = MathRenderer::getRenderer( "a+b", array(), MW_MATH_LATEXML );
$this->assertTrue( $renderer->render( true ) );
$expected = '<math xmlns="http://www.w3.org/1998/Math/MathML" id="p1.1.m1" class="ltx_Math" alttext="{\displaystyle a+b}" display="inline" xml:id="p1.1.m1.1" xref="p1.1.m1.1.cmml"><semantics xml:id="p1.1.m1.1a" xref="p1.1.m1.1.cmml"><mrow xml:id="p1.1.m1.1.4" xref="p1.1.m1.1.4.cmml"><mi xml:id="p1.1.m1.1.1" xref="p1.1.m1.1.1.cmml">a</mi><mo xml:id="p1.1.m1.1.2" xref="p1.1.m1.1.2.cmml">+</mo><mi xml:id="p1.1.m1.1.3" xref="p1.1.m1.1.3.cmml">b</mi></mrow><annotation-xml encoding="MathML-Content" xml:id="p1.1.m1.1.cmml" xref="p1.1.m1.1"><apply xml:id="p1.1.m1.1.4.cmml" xref="p1.1.m1.1.4"><plus xml:id="p1.1.m1.1.2.cmml" xref="p1.1.m1.1.2"/><ci xml:id="p1.1.m1.1.1.cmml" xref="p1.1.m1.1.1">a</ci><ci xml:id="p1.1.m1.1.3.cmml" xref="p1.1.m1.1.3">b</ci></apply></annotation-xml><annotation encoding="application/x-tex" xml:id="p1.1.m1.1b" xref="p1.1.m1.1.cmml">{\displaystyle a+b}</annotation></semantics></math>';
$expected = '<math xmlns="http://www.w3.org/1998/Math/MathML" id="p1.1.m1" class="ltx_Math" alttext="{\displaystyle a+b}" xml:id="p1.1.m1.1" xref="p1.1.m1.1.cmml"><semantics xml:id="p1.1.m1.1a" xref="p1.1.m1.1.cmml"><mrow xml:id="p1.1.m1.1.4" xref="p1.1.m1.1.4.cmml"><mi xml:id="p1.1.m1.1.1" xref="p1.1.m1.1.1.cmml">a</mi><mo xml:id="p1.1.m1.1.2" xref="p1.1.m1.1.2.cmml">+</mo><mi xml:id="p1.1.m1.1.3" xref="p1.1.m1.1.3.cmml">b</mi></mrow><annotation-xml encoding="MathML-Content" xml:id="p1.1.m1.1.cmml" xref="p1.1.m1.1"><apply xml:id="p1.1.m1.1.4.cmml" xref="p1.1.m1.1.4"><plus xml:id="p1.1.m1.1.2.cmml" xref="p1.1.m1.1.2"/><ci xml:id="p1.1.m1.1.1.cmml" xref="p1.1.m1.1.1">a</ci><ci xml:id="p1.1.m1.1.3.cmml" xref="p1.1.m1.1.3">b</ci></apply></annotation-xml><annotation encoding="application/x-tex" xml:id="p1.1.m1.1b" xref="p1.1.m1.1.cmml">{\displaystyle a+b}</annotation></semantics></math>';
$real = preg_replace( "/\n\s*/", '', $renderer->getHtmlOutput() );
$this->assertContains( $expected, $real
, "Rendering of a+b in plain Text mode." .