Physikerwelt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/192863
Change subject: Merge recent changes from master
......................................................................
Merge recent changes from master
conflicts:
Math.alias.php
Math.hooks.php
MathMathML.php
tests/MathLaTeXMLTest.php
tests/MathMathMLTest.php
tests/MathRendererTest.php
Change-Id: I0b3f2afaf0716755e9f5e51334290422c0bc459d
---
M Math.hooks.php
M MathInputCheckTexvc.php
M MathLaTeXML.php
M MathMathML.php
M MathRenderer.php
M MathTexvc.php
M i18n/avk.json
M i18n/en.json
M i18n/nds-nl.json
M i18n/sl.json
M tests/MathMathMLTest.php
M tests/MathRendererTest.php
M tests/browser/features/math.feature
M tests/browser/features/step_definitions/math_steps.rb
14 files changed, 158 insertions(+), 113 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math
refs/changes/63/192863/3
diff --git a/Math.hooks.php b/Math.hooks.php
index cc3af32..39d18b9 100644
--- a/Math.hooks.php
+++ b/Math.hooks.php
@@ -97,7 +97,6 @@
return '';
}
- wfProfileIn( __METHOD__ );
$mode = (int)$parser->getUser()->getOption( 'math' );
// Indicate that this page uses math.
@@ -139,7 +138,6 @@
}
// Writes cache if rendering was successful
$renderer->writeCache();
- wfProfileOut( __METHOD__ );
return array( $renderedMath, "markerType" => 'nowiki' );
}
diff --git a/MathInputCheckTexvc.php b/MathInputCheckTexvc.php
index 9023fc7..b2eb6a6 100644
--- a/MathInputCheckTexvc.php
+++ b/MathInputCheckTexvc.php
@@ -60,7 +60,7 @@
public function doValidCheck() {
global $wgMathTexvcCheckExecutable;
if ( !is_executable( $wgMathTexvcCheckExecutable ) ) {
- $msg = wfMessage( 'math_notexvccheck'
)->inContentLanguage()->escaped();
+ $msg = 'Missing "texvccheck" executable. Please see
math/README to configure.';
trigger_error( $msg, E_USER_NOTICE );
wfDebugLog( 'Math', $msg );
return true;
diff --git a/MathLaTeXML.php b/MathLaTeXML.php
index 318d652..7734290 100644
--- a/MathLaTeXML.php
+++ b/MathLaTeXML.php
@@ -94,7 +94,7 @@
*/
protected function doRender() {
global $wgMathDebug;
- wfProfileIn( __METHOD__ );
+
if ( trim( $this->getTex() ) === '' ) {
wfDebugLog( "Math", "Rendering was requested, but no
TeX string is specified." );
$this->lastError = $this->getError( 'math_empty_tex' );
@@ -131,7 +131,6 @@
wfDebugLog( "Math", "\nLaTeXML
InvalidMathML:"
. var_export( array(
'post' => $post, 'host' => $host
, 'result' => $res ),
true ) . "\n\n" );
- wfProfileOut( __METHOD__ );
return false;
}
} else {
@@ -139,12 +138,10 @@
wfDebugLog( "Math", "\nLaTeXML
InvalidJSON:"
. var_export( array( 'post' =>
$post, 'host' => $host
, 'res' => $res ), true ) .
"\n\n" );
- wfProfileOut( __METHOD__ );
return false;
}
} else {
// Error message has already been set.
- wfProfileOut( __METHOD__ );
return false;
}
}
diff --git a/MathMathML.php b/MathMathML.php
index c32e796..b630085 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -82,15 +82,12 @@
* @see MathRenderer::render()
*/
public function render( $forceReRendering = false ) {
- wfProfileIn( __METHOD__ );
if ( $forceReRendering ) {
$this->setPurge( true );
}
if ( $this->renderingRequired() ) {
- wfProfileOut( __METHOD__ );
- return $this->doRender( );
+ return $this->doRender();
}
- wfProfileOut( __METHOD__ );
return true;
}
@@ -143,7 +140,6 @@
// TODO: Change the timeout mechanism.
global $wgMathLaTeXMLTimeout;
- wfProfileIn( __METHOD__ );
$error = '';
$res = null;
if ( !$host ) {
@@ -159,7 +155,6 @@
$status = $req->execute();
if ( $status->isGood() ) {
$res = $req->getContent();
- wfProfileOut( __METHOD__ );
return true;
} else {
if ( $status->hasMessage( 'http-timed-out' ) ) {
@@ -176,7 +171,6 @@
. var_export( array( 'post' => $post,
'host' => $host
, 'errormsg' => $errormsg ), true ) .
"\n\n" );
}
- wfProfileOut( __METHOD__ );
return false;
}
}
@@ -194,7 +188,7 @@
} else {
$host = $this->hosts;
}
- wfDebugLog( "Math", "picking host " . $host );
+ wfDebugLog( 'Math', 'picking host ' . $host );
return $host;
}
@@ -236,7 +230,6 @@
$host = self::pickHost();
$post = $this->getPostData();
$this->lastError = '';
- if( $wgMathDebug ) { $renderingStart = microtime( true ); }
$requestResult = $this->makeRequest( $host, $post, $res,
$this->lastError );
if( $wgMathDebug ) { $this->setRenderingTime( microtime( true )
- $renderingStart ); }
if ( $requestResult ) {
@@ -302,13 +295,7 @@
if ( !$this->XMLValidation ) {
return true;
}
- // depends on https://gerrit.wikimedia.org/r/#/c/66365/
- if ( !is_callable( 'XmlTypeCheck::newFromString' ) ) {
- $msg = wfMessage( 'math_xmlversion'
)->inContentLanguage()->escaped();
- trigger_error( $msg, E_USER_NOTICE );
- wfDebugLog( 'Math', $msg );
- return true;
- }
+
$xmlObject = new XmlTypeCheck( $XML, null, false );
if ( !$xmlObject->wellFormed ) {
wfDebugLog( 'Math', "XML validation error:\n " .
var_export( $XML, true ) . "\n" );
@@ -474,4 +461,39 @@
}
+ /**
+ * @param $jsonResult
+ * @param $host
+ *
+ * @return bool
+ */
+ private function processJsonResult( $jsonResult, $host ) {
+ global $wgMathDebug;
+ if ( $this->getMode() == MW_MATH_LATEXML || $this->inputType ==
'pmml' ||
+ $this->isValidMathML( $jsonResult->mml )
+ ) {
+ if ( isset( $jsonResult->svg ) ) {
+ $xmlObject = new XmlTypeCheck(
$jsonResult->svg, null, false );
+ if ( !$xmlObject->wellFormed ) {
+ $this->lastError = $this->getError(
'math_invalidxml', $host );
+ return false;
+ } else {
+ $this->setSvg( $jsonResult->svg );
+ }
+ } else {
+ wfDebugLog( 'Math', 'Missing SVG property in
JSON result.' );
+ }
+ if ( $wgMathDebug ) {
+ $this->setLog( $jsonResult->log );
+ }
+ if ( $this->getMode() != MW_MATH_LATEXML &&
$this->inputType != 'pmml' ) {
+ $this->setMathml( $jsonResult->mml );
+ }
+ return true;
+ } else {
+ $this->lastError = $this->getError(
'math_unknown_error', $host );
+ return false;
+ }
+ }
+
}
diff --git a/MathRenderer.php b/MathRenderer.php
index 2654298..115331f 100644
--- a/MathRenderer.php
+++ b/MathRenderer.php
@@ -263,7 +263,6 @@
* @return boolean true if read successfully, false otherwise
*/
public function readFromDatabase() {
- wfProfileIn( __METHOD__ );
/** @var DatabaseBase */
$dbr = wfGetDB( DB_SLAVE );
/** @var ResultWrapper */
@@ -274,12 +273,10 @@
if ( $rpage !== false ) {
$this->initializeFromDatabaseRow( $rpage );
$this->storedInDatabase = true;
- wfProfileOut( __METHOD__ );
return true;
} else {
# Missing from the database and/or the render cache
$this->storedInDatabase = false;
- wfProfileOut( __METHOD__ );
return false;
}
}
@@ -464,12 +461,7 @@
* @return string in UTF-8 encoding
*/
public function getMathml() {
- if ( ! is_callable( 'StringUtils::isUtf8' ) ) {
- $msg = wfMessage( 'math_latexml_xmlversion'
)->inContentLanguage()->escaped();
- trigger_error( $msg, E_USER_NOTICE );
- wfDebugLog( 'Math', $msg );
- // If we can not check if mathml output is valid, we
skip the test and assume that it is valid.
- } elseif ( ! StringUtils::isUtf8( $this->mathml ) ) {
+ if ( !StringUtils::isUtf8( $this->mathml ) ) {
$this->setMathml( '' );
}
return $this->mathml;
diff --git a/MathTexvc.php b/MathTexvc.php
index 562af16..a2f6113 100644
--- a/MathTexvc.php
+++ b/MathTexvc.php
@@ -174,11 +174,9 @@
public function callTexvc() {
global $wgTexvc, $wgTexvcBackgroundColor, $wgHooks;
- wfProfileIn( __METHOD__ );
$tmpDir = wfTempDir();
if ( !is_executable( $wgTexvc ) ) {
wfDebugLog( 'texvc', "$wgTexvc does not exist or is not
executable." );
- wfProfileOut( __METHOD__ );
return $this->getError( 'math_notexvc' );
}
@@ -204,11 +202,9 @@
if ( strlen( $contents ) == 0 ) {
if ( !file_exists( $tmpDir ) || !is_writable( $tmpDir )
) {
wfDebugLog( 'texvc', "TeX output directory
$tmpDir is missing or not writable" );
- wfProfileOut( __METHOD__ );
return $this->getError( 'math_bad_tmpdir' );
} else {
wfDebugLog( 'texvc', "TeX command '$cmd'
returned no output and status code $retval." );
- wfProfileOut( __METHOD__ );
return $this->getError( 'math_unknown_error' );
}
}
@@ -265,16 +261,12 @@
wfRunHooks( 'MathAfterTexvc', array( &$this, &$errmsg ) );
if ( $errmsg ) {
- wfProfileOut( __METHOD__ );
return $errmsg;
} elseif ( !preg_match( "/^[a-f0-9]{32}$/", $this->getHash() )
) {
- wfProfileOut( __METHOD__ );
return $this->getError( 'math_unknown_error' );
} elseif ( !file_exists( "$tmpDir/{$this->getHash()}.png" ) ) {
- wfProfileOut( __METHOD__ );
return $this->getError( 'math_image_error' );
} elseif ( filesize( "$tmpDir/{$this->getHash()}.png" ) == 0 ) {
- wfProfileOut( __METHOD__ );
return $this->getError( 'math_image_error' );
}
@@ -283,7 +275,6 @@
$backend = $this->getBackend();
# Create any containers/directories as needed...
if ( !$backend->prepare( array( 'dir' => $hashpath ) )->isOK()
) {
- wfProfileOut( __METHOD__ );
return $this->getError( 'math_output_error' );
}
// Store the file at the final storage path...
@@ -304,7 +295,6 @@
'ref' => $tempFsFile // keep file alive
);
- wfProfileOut( __METHOD__ );
return self::MW_TEXVC_SUCCESS;
}
@@ -367,7 +357,6 @@
public function writeCache() {
global $wgUseSquid;
- wfProfileIn( __METHOD__ );
$updated = parent::writeCache();
// If we're replacing an older version of the image, make sure
it's current.
if ( $updated && $wgUseSquid ) {
@@ -375,7 +364,7 @@
$u = new SquidUpdate( $urls );
$u->doUpdate();
}
- wfProfileOut( __METHOD__ );
+
return $updated;
}
@@ -387,11 +376,9 @@
public function readCache() {
global $wgMathCheckFiles;
- wfProfileIn( __METHOD__ );
if ( $this->isInDatabase() ) {
if ( !$wgMathCheckFiles ) {
// Short-circuit the file existence & migration
checks
- wfProfileOut( __METHOD__ );
return true;
}
$filename = $this->getHashPath() .
"/{$this->getHash()}.png"; // final storage path
@@ -401,12 +388,10 @@
// Some horrible error corrupted stuff
:(
$backend->quickDelete( array( 'src' =>
$filename ) );
} else {
- wfProfileOut( __METHOD__ );
return true; // cache hit
}
}
}
- wfProfileOut( __METHOD__ );
return false;
}
public function getPng() {
diff --git a/i18n/avk.json b/i18n/avk.json
index 3f375b4..fa4b5b2 100644
--- a/i18n/avk.json
+++ b/i18n/avk.json
@@ -1,18 +1,22 @@
{
- "@metadata": [],
- "math_sample": "Va rinaf tazukoy batliz cenkal",
- "math_tip": "Solokseropaf tazukoy (LaTeX)",
- "prefs-math": "Rendu des maths",
- "mw_math_png": "Toujours produire une image PNG",
- "mw_math_source": "Laisser le code TeX original",
- "mw_math_mathml": "MathML",
+ "@metadata": {
+ "authors": [
+ "Zetud"
+ ]
+ },
+ "math_bad_output": "Redura ik sutera ko divaxo tid merotisa",
+ "math_bad_tmpdir": "Redura ik sutera ko ugaloraxo tid merotisa",
"math_failure": "Erreur math",
+ "math_image_error": "La conversion en PNG a échoué, vérifiez
l'installation de Latex, dvips, gs et convert",
+ "math_lexing_error": "ravlemafa rokla",
+ "math_notexvc": "L'éxécutable « <code>texvc</code> » est introuvable.
Lisez math/README pour le configurer.",
+ "math_sample": "Va rinaf tazukoy batliz cenkal",
+ "math_syntax_error": "erurafa rokla",
+ "math_tip": "Solokseropaf tazukoy (LaTeX)",
"math_unknown_error": "erreur indéterminée",
"math_unknown_function": "megrupen fliok",
- "math_lexing_error": "ravlemafa rokla",
- "math_syntax_error": "erurafa rokla",
- "math_image_error": "La conversion en PNG a échouée, vérifiez
l'installation de Latex, dvips, gs et convert",
- "math_bad_tmpdir": "Redura ik sutera ko ugaloraxo tid merotisa",
- "math_bad_output": "Redura ik sutera ko divaxo tid merotisa",
- "math_notexvc": "L'éxécutable « <code>texvc</code> » est introuvable.
Lisez math/README pour le configurer."
+ "mw_math_mathml": "MathML",
+ "mw_math_png": "Toujours produire une image PNG",
+ "mw_math_source": "Laisser le code TeX original",
+ "prefs-math": "Rendu des maths"
}
diff --git a/i18n/en.json b/i18n/en.json
index 5c9d868..4a6e580 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -23,7 +23,6 @@
"math_lexing_error": "lexing error",
"math_mathoid_error": "Conversion error. Server (\"$1\") reported: \"$2\"",
"math_notexvc": "Missing <code>texvc</code> executable. Please see
math/README to configure.",
- "math_notexvccheck": "Missing <code>texvccheck</code> executable. Please
see math/README to configure.",
"math_output_error": "Cannot store math image on filesystem.",
"math_sample": "Insert formula here",
"math-status-introduction" : "This page displays information about the
enabled math rendering modes.\n\nThe following rendering mode is/rendering
modes are enabled.",
@@ -36,7 +35,6 @@
"math_tip": "Mathematical formula (LaTeX)",
"math_unknown_error": "unknown error",
"math_unknown_function": "unknown function \"$1\"",
- "math_xmlversion": "Warning: XML type check skipped! Check if your
MediaWiki installation is version wmf/1.22wmf7 or newer.",
"mw_math_latexml": "LaTeXML (experimental; uses MathML)",
"mw_math_latexml_jax": "LaTeXML with client-side MathJax (experimental;
uses MathML)",
"mw_math_mathjax": "Client-side MathJax (slow; improves rendering on some
browsers and accessibility tools)",
diff --git a/i18n/nds-nl.json b/i18n/nds-nl.json
index a3e1e8c..6375bd5 100644
--- a/i18n/nds-nl.json
+++ b/i18n/nds-nl.json
@@ -5,26 +5,26 @@
]
},
"math-desc": "Wiskundige formules tussen <code><math></code> ...
<code></math></code>-etiketten zetten",
- "math_sample": "Voer de formule in",
- "math_tip": "Wiskundige formule (in LaTeX)",
- "prefs-math": "Wiskundige formules",
- "mw_math_png": "Altied as PNG laoten zien",
- "mw_math_source": "Laot TeX-bronkode staon (veur tekstwebkiekers)",
- "mw_math_mathjax": "MathJax (experimenteel)",
- "mw_math_mathml": "MathML",
- "mw_math_latexml": "LaTeXML (experimenteel; gebruukt MathML)",
- "math_failure": "Wiskundige formule niet begriepelik",
- "math_unknown_error": "Onbekende fout in formule",
- "math_unknown_function": "onbekende funksie \"$1\"",
- "math_lexing_error": "Lexikografiese fout in formule",
- "math_syntax_error": "Syntaktiese fout in formule",
- "math_image_error": "De PNG-umzetting is mislokt. Kiek even nao of
LaTeX en dvipng (of dvips + gs + convert) wel goed eïnstalleerd bin.",
- "math_bad_tmpdir": "De map veur tiedelike bestaanden veur wiskundige
formules besteet niet of is kan niet an-emaakt wörden.",
+ "math-visualeditor-mwmathinspector-display-default": "Standard",
"math_bad_output": "De map veur wiskundebestaanden besteet niet of is
niet an te maken.",
- "math_notexvc": "Kan t programma <code>texvc</code> niet vienen;
configureer volgens de beschrieving in math/README.",
- "math_output_error": "De formule-aofbeelding kan niet op t
bestaandssysteem op-esleugen wörden.",
+ "math_bad_tmpdir": "De map veur tiedelike bestaanden veur wiskundige
formules besteet niet of is kan niet an-emaakt wörden.",
+ "math_failure": "Wiskundige formule niet begriepelik",
+ "math_image_error": "De PNG-umzetting is mislokt. Kiek even nao of
LaTeX en dvipng (of dvips + gs + convert) wel goed eïnstalleerd bin.",
+ "math_invalidjson": "$1: t antwoord van de server is ongeldige JSON.",
"math_invalidresponse": "$1: ongeldig antwoord (\"$3\") van server
\"$2\":",
"math_invalidxml": ": MathML is ongeldige XML.",
- "math_invalidjson": "$1: t antwoord van de server is ongeldige JSON.",
- "math_xmlversion": "Waorschuwing: XML-typekontraole overesleugen. Kiek
nao of joew MediaWiki-installasie versie 1.22wmf7 of laoter is."
+ "math_lexing_error": "Lexikografiese fout in formule",
+ "math_notexvc": "Kan t programma <code>texvc</code> niet vienen;
configureer volgens de beschrieving in math/README.",
+ "math_output_error": "De formule-aofbeelding kan niet op t
bestaandssysteem op-esleugen wörden.",
+ "math_sample": "Voer de formule in",
+ "math_syntax_error": "Syntaktiese fout in formule",
+ "math_tip": "Wiskundige formule (in LaTeX)",
+ "math_unknown_error": "Onbekende fout in formule",
+ "math_unknown_function": "onbekende funksie \"$1\"",
+ "mw_math_latexml": "LaTeXML (experimenteel; gebruukt MathML)",
+ "mw_math_mathjax": "MathJax (experimenteel)",
+ "mw_math_mathml": "MathML",
+ "mw_math_png": "Altied as PNG laoten zien",
+ "mw_math_source": "Laot TeX-bronkode staon (veur tekstwebkiekers)",
+ "prefs-math": "Wiskundige formules"
}
diff --git a/i18n/sl.json b/i18n/sl.json
index 5888328..7c4e0a8 100644
--- a/i18n/sl.json
+++ b/i18n/sl.json
@@ -5,33 +5,36 @@
]
},
"math-desc": "Izriši matematične formule med oznakama
<code><math></code> in <code></math></code>",
- "math_sample": "Tu vnesite enačbo",
- "math_tip": "Matematična enačba (LaTeX)",
- "prefs-math": "Prikaz matematičnega besedila",
- "mw_math_png": "Slike PNG",
- "mw_math_source": "Vir TeX (za besedilne brskalnike)",
- "mw_math_mathjax": "MathJax na strani odjemalca (poskusno, izboljša
upodabljanje v nekaterih brskalnikih in pripomočkih za dostopnost)",
- "mw_math_mathml": "MathML z rezervo SVG ali PNG (priporočeno za sodobne
brskalnike in pripomočke za dostopnost)",
- "mw_math_latexml": "LaTeXML (poskusno; uporablja MathML)",
- "mw_math_latexml_jax": "LaTeXML z MathJax na strani odjemalca
(poskusno; uporablja MathML)",
- "math_failure": "Ni mi uspelo razčleniti",
- "math_unknown_error": "neznana napaka",
- "math_unknown_function": "neznana funkcija '$1'",
- "math_lexing_error": "slovarska napaka",
- "math_syntax_error": "skladenjska napaka",
- "math_image_error": "Pretvarjanje v PNG ni uspelo; preverite, ali sta
latex in dvips (ali dvips + gs + convert) pravilno nameščena.",
- "math_bad_tmpdir": "Začasne mape za math ne morem ustvariti ali pisati
vanjo.",
+ "math-preference-mwmathinspector-description": "Dodaj preizkusno
podporo za ustvarjanje in urejanje matematičnih izrazov v VirtualEditor za
preizkušanje pred splošnim izidom. Prosimo, da pri uporabi preizkusnih funkcij
vedno pregledate svoje spremembe pred shranjevanjem.",
+ "math-preference-mwmathinspector-label": "Urejanje formul VisualEditor",
+ "math-visualeditor-mwmathinspector-display": "Prikaz",
+ "math-visualeditor-mwmathinspector-display-block": "Blokiraj",
+ "math-visualeditor-mwmathinspector-display-default": "Privzeto",
+ "math-visualeditor-mwmathinspector-display-inline": "V vrstici",
+ "math-visualeditor-mwmathinspector-id": "ID povezave (neobvezno)",
+ "math-visualeditor-mwmathinspector-title": "Formula",
"math_bad_output": "Izhodne mape za math ne morem ustvariti ali pisati
vanjo.",
- "math_notexvc": "Manjka izvedbena datoteka <code>texvc</code>;\nza
njeno namestitev si poglejte math/README.",
- "math_notexvccheck": "Manjka izvršljiva datoteka
<code>texvccheck</code>; prosimo, oglejte si math/README za konfiguracijo.",
- "math_output_error": "Ne morem shraniti matematičnih slik na datotečni
sistem.",
- "math_timeout": "Potekla časovna omejitev $1 na »$2«",
+ "math_bad_tmpdir": "Začasne mape za math ne morem ustvariti ali pisati
vanjo.",
+ "math_failure": "Ni mi uspelo razčleniti",
+ "math_image_error": "Pretvarjanje v PNG ni uspelo; preverite, ali sta
latex in dvips (ali dvips + gs + convert) pravilno nameščena.",
+ "math_invalidjson": "Odziv strežnika $1 ni veljaven JSON.",
"math_invalidresponse": "$1: Neveljavni odziv (»$3«) strežnika »$2«:",
"math_invalidxml": "MathML ali SVG ni veljaven XML.",
- "math_invalidjson": "Odziv strežnika $1 ni veljaven JSON.",
+ "math_lexing_error": "slovarska napaka",
"math_mathoid_error": "Napaka pri pretvorbi. Strežnik (»$1«) je
sporočil: »$2«",
- "math_xmlversion": "Opozorilo: Preverjanje vrste XML sem preskočil!
Preverite, če je vaša namestitev MediaWiki različice wmf/1.22wmf7 ali novejša.",
- "math-visualeditor-mwmathinspector-title": "Formula",
- "math-preference-mwmathinspector-description": "Dodaj preizkusno
podporo za ustvarjanje in urejanje matematičnih izrazov v VirtualEditor za
preizkušanje pred splošnim izidom. Prosimo, da pri uporabi preizkusnih funkcij
vedno pregledate svoje spremembe pred shranjevanjem.",
- "math-preference-mwmathinspector-label": "Urejanje formul VisualEditor"
+ "math_notexvc": "Manjka izvedbena datoteka <code>texvc</code>;\nza
njeno namestitev si poglejte math/README.",
+ "math_output_error": "Ne morem shraniti matematičnih slik na datotečni
sistem.",
+ "math_sample": "Tu vnesite enačbo",
+ "math_syntax_error": "skladenjska napaka",
+ "math_timeout": "Potekla časovna omejitev $1 na »$2«",
+ "math_tip": "Matematična enačba (LaTeX)",
+ "math_unknown_error": "neznana napaka",
+ "math_unknown_function": "neznana funkcija '$1'",
+ "mw_math_latexml": "LaTeXML (poskusno; uporablja MathML)",
+ "mw_math_latexml_jax": "LaTeXML z MathJax na strani odjemalca
(poskusno; uporablja MathML)",
+ "mw_math_mathjax": "MathJax na strani odjemalca (poskusno, izboljša
upodabljanje v nekaterih brskalnikih in pripomočkih za dostopnost)",
+ "mw_math_mathml": "MathML z rezervo SVG ali PNG (priporočeno za sodobne
brskalnike in pripomočke za dostopnost)",
+ "mw_math_png": "Slike PNG",
+ "mw_math_source": "Vir TeX (za besedilne brskalnike)",
+ "prefs-math": "Prikaz matematičnega besedila"
}
diff --git a/tests/MathMathMLTest.php b/tests/MathMathMLTest.php
index 610b536..6c33eae 100644
--- a/tests/MathMathMLTest.php
+++ b/tests/MathMathMLTest.php
@@ -104,6 +104,51 @@
$this->assertFalse( $renderer->isValidMathML( $invalidSample ),
'test if math expression is invalid mathml sample' );
}
+
+ /**
+ * Checks the basic functionality
+ * i.e. if the span element is generated right.
+ */
+ public function testIntegration() {
+ global $wgMathMathMLTimeout;
+ $svgRef = '<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns:xlink="http://www.w3.org/1999/xlink" style="vertical-align:
-0.333ex; " width="5.167ex" height="1.833ex" viewBox="0 -717.9 2195.4 823.9"
xmlns="http://www.w3.org/2000/svg">
+<defs>
+<path stroke-width="10" id="E1-MJMATHI-61" d="M33 157Q33 258 109 349T280
441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374
68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153
483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10
393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172
-10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210
374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26
254 59T298 110Q300 114 325 217T351 328Z"></path>
+<path stroke-width="10" id="E1-MJMAIN-2B" d="M56 237T56 250T70 270H369V420L370
570Q380 583 389 583Q402 583 409 568V270H707Q722 262 722 250T707 230H409V-68Q401
-82 391 -82H389H387Q375 -82 369 -68V230H70Q56 237 56 250Z"></path>
+<path stroke-width="10" id="E1-MJMATHI-62" d="M73 647Q73 657 77 670T89 683Q90
683 161 688T234 694Q246 694 246 685T212 542Q204 508 195 472T180 418L176 399Q176
396 182 402Q231 442 283 442Q345 442 383 396T422 280Q422 169 343 79T173 -11Q123
-11 82 27T40 150V159Q40 180 48 217T97 414Q147 611 147 623T109 637Q104 637 101
637H96Q86 637 83 637T76 640T73 647ZM336 325V331Q336 405 275 405Q258 405 240
397T207 376T181 352T163 330L157 322L136 236Q114 150 114 114Q114 66 138 42Q154
26 178 26Q211 26 245 58Q270 81 285 114T318 219Q336 291 336 325Z"></path>
+</defs>
+<g stroke="black" fill="black" stroke-width="0" transform="matrix(1 0 0 -1 0
0)">
+ <use xlink:href="#E1-MJMATHI-61"></use>
+ <use xlink:href="#E1-MJMAIN-2B" x="756" y="0"></use>
+ <use xlink:href="#E1-MJMATHI-62" x="1761" y="0"></use>
+</g>
+</svg>';
+ $wgMathMathMLTimeout = 20;
+ $renderer = MathRenderer::getRenderer( "a+b", array(),
MW_MATH_MATHML );
+ $this->assertTrue( $renderer->render( true ) );
+ $real = str_replace( "\n", '', $renderer->getHtmlOutput() );
+ $expected = '<mo>+</mo>';
+ $this->assertContains( $expected, $real, "Rendering of a+b in
plain MathML mode" );
+ $this->assertEquals( $svgRef, $renderer->getSvg() );
+ }
+
+ /**
+ * Checks the experimental option to 'render' MathML input
+ */
+ public function testPmmlInput() {
+ // sample from 'Navajo Coal Combustion and Respiratory Health
Near Shiprock, New Mexico' in ''Journal of Environmental and Public Health'' ,
vol. 2010p.
+ // authors Joseph E. Bunnell; Linda V. Garcia; Jill M.
Furst; Harry Lerch; Ricardo A. Olea; Stephen E. Suitt; Allan Kolker
+ $inputSample = '<msub> <mrow> <mi> P</mi> </mrow> <mrow>
<mi> i</mi> <mi> j</mi> </mrow> </msub> <mo> =</mo> <mfrac> <mrow> <mn>
100</mn> <msub> <mrow> <mi> d</mi> </mrow> <mrow> <mi> i</mi> <mi> j</mi>
</mrow> </msub> </mrow> <mrow> <mn> 6.75</mn> <msub> <mrow> <mi> r</mi>
</mrow> <mrow> <mi> j</mi> </mrow> </msub> </mrow> </mfrac> <mo> ,</mo>
</math>';
+ $attribs = array( 'type' => 'pmml' );
+ $renderer = new MathMathML( $inputSample, $attribs );
+ $this->assertEquals( 'pmml', $renderer->getInputType(), 'Input
type was not set correctly' );
+ $this->assertTrue( $renderer->render(), 'Failed to render with
error:' . $renderer->getLastError() );
+ $real = MathRenderer::renderMath( $inputSample, $attribs,
MW_MATH_MATHML );
+ $expected = 'hash=5628b8248b79267ecac656102334d5e3&mode=5';
+ $this->assertContains( $expected, $real, 'Link to SVG image
missing' );
+ }
}
/**
diff --git a/tests/MathRendererTest.php b/tests/MathRendererTest.php
index 310ddec..25696d9 100644
--- a/tests/MathRendererTest.php
+++ b/tests/MathRendererTest.php
@@ -153,4 +153,5 @@
$renderer->setRenderingTime(4321);
$this->assertEquals( 4321, $renderer->getRenderingTime(),
"Check time integer input");
}
-}
\ No newline at end of file
+}
+
diff --git a/tests/browser/features/math.feature
b/tests/browser/features/math.feature
index 1b5db83..3f9e83b 100644
--- a/tests/browser/features/math.feature
+++ b/tests/browser/features/math.feature
@@ -15,8 +15,8 @@
Scenario: Display simple math
Given I am logged in
And I am at page that does not exist
- And I click link Create source
- When I type <math>3 + 2</math>
+ When I click link Create source
+ And I type <math>3 + 2</math>
And I click Preview
Then the page should contain an img tag
And alt for that img should be 3 + 2
diff --git a/tests/browser/features/step_definitions/math_steps.rb
b/tests/browser/features/step_definitions/math_steps.rb
index 6bb9456..98843e8 100644
--- a/tests/browser/features/step_definitions/math_steps.rb
+++ b/tests/browser/features/step_definitions/math_steps.rb
@@ -27,14 +27,14 @@
end
Then(/^alt for that img should be (.+)$/) do |alt|
- on(EditPage).math_image_element.element.alt.should == alt
+ expect(on(EditPage).math_image_element.element.alt).to eq(alt)
end
Then(/^src for that img should come from (.+)$/) do |src|
- on(EditPage).math_image_element.element.src.should match Regexp.escape(src)
+ expect(on(EditPage).math_image_element.element.src).to match
Regexp.escape(src)
end
Then(/^the page should contain an img tag$/) do
- on(EditPage).math_image_element.when_present.should be_visible
+ expect(on(EditPage).math_image_element.when_present).to be_visible
end
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/192863
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b3f2afaf0716755e9f5e51334290422c0bc459d
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: debug
Gerrit-Owner: Physikerwelt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits