Display MathML when MathPlayer is installed

When MathPlayer is installed, we show the MathML instead of the SVG fallback.
This will in particular allow the sync highlighting feature of MathPlayer.
This also introduces a module ext.math.js that could be used to do some
Javascript postprocessing.

Bug: 71748
Change-Id: I438a20032c312d12321ca4c5686bcfd107656b37
This commit is contained in:
Frédéric Wang 2014-10-10 12:38:23 +02:00
parent b59a37640c
commit c3894c2c49
5 changed files with 22 additions and 3 deletions

View File

@ -135,6 +135,7 @@ class MathHooks {
$parser->getOutput()->addModules( array( 'ext.math.mathjax.enabler' ) );
}
$parser->getOutput()->addModuleStyles( array( 'ext.math.styles' ) );
$parser->getOutput()->addModules( array( 'ext.math.scripts' ) );
// Writes cache if rendering was successful
$renderer->writeCache();

View File

@ -235,6 +235,11 @@ $wgResourceModules['ext.math.styles'] = array(
'remoteExtPath' => 'Math/modules',
'styles' => 'ext.math.css',
);
$wgResourceModules['ext.math.scripts'] = array(
'localBasePath' => __DIR__ . '/modules',
'remoteExtPath' => 'Math/modules',
'scripts' => 'ext.math.js',
);
// MathJax module
// If you modify these arrays, update ext.math.mathjax.enabler.js to ensure

View File

@ -424,6 +424,9 @@ class MathMathML extends MathRenderer {
} else {
$class .= 'inline';
}
if ( !$fallback) {
$class .= ' mwe-math-mathml-a11y';
}
return $class;
}
/**

View File

@ -10,8 +10,8 @@
/* Default style for MathML. */
.mwe-math-mathml-inline { display: inline !important; }
.mwe-math-mathml-display { display: block !important; margin-left: auto; margin-right: auto; }
.mwe-math-mathml-inline, .mwe-math-mathml-display {
/* We try to hide the MathML formula in a way that still makes it accessible to screen readers. */
.mwe-math-mathml-a11y {
/* We try to hide the MathML formula in a way that still makes it accessible to accessibility tools. */
clip: rect(1px, 1px, 1px, 1px);
overflow: hidden;
position: absolute;
@ -59,7 +59,7 @@ img.mwe-math-fallback-png-display { display: block; }
@-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, .mwe-math-mathml-display {
.mwe-math-mathml-a11y {
clip: auto;
overflow: visible;
position: static;

10
modules/ext.math.js Normal file
View File

@ -0,0 +1,10 @@
( function ( $ ) {
'use strict';
// If MathPlayer is installed we show the MathML rendering.
if (navigator.userAgent.indexOf('MathPlayer') > -1) {
$( '.mwe-math-mathml-a11y' ).removeClass( 'mwe-math-mathml-a11y' );
$( 'img' ).removeClass( 'mwe-math-fallback-svg-inline mwe-math-fallback-svg-display' );
}
// FIXME: for browsers without SVG support, the <img> fallback should be
// updated to point to PNG images.
}( jQuery ) );