mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-12 01:08:55 +00:00
Ignore missing SVG attribute
In some cases the SVG property of the mathoid JSON result seems to be empty. In that case we ignore the SVG rendering. Bug: T87379 Change-Id: I98398ec59e1d0205ee32cca137ad29dbc9dddec9
This commit is contained in:
parent
eab415ef71
commit
77e82d89af
|
@ -220,7 +220,6 @@ class MathMathML extends MathRenderer {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function doRender() {
|
protected function doRender() {
|
||||||
global $wgMathDebug;
|
|
||||||
if ( $this->getTex() === '' ) {
|
if ( $this->getTex() === '' ) {
|
||||||
wfDebugLog( 'Math', 'Rendering was requested, but no TeX string is specified.' );
|
wfDebugLog( 'Math', 'Rendering was requested, but no TeX string is specified.' );
|
||||||
$this->lastError = $this->getError( 'math_empty_tex' );
|
$this->lastError = $this->getError( 'math_empty_tex' );
|
||||||
|
@ -235,27 +234,7 @@ class MathMathML extends MathRenderer {
|
||||||
$jsonResult = json_decode( $res );
|
$jsonResult = json_decode( $res );
|
||||||
if ( $jsonResult && json_last_error() === JSON_ERROR_NONE ) {
|
if ( $jsonResult && json_last_error() === JSON_ERROR_NONE ) {
|
||||||
if ( $jsonResult->success ) {
|
if ( $jsonResult->success ) {
|
||||||
if ( $this->getMode() == MW_MATH_LATEXML ||
|
return $this->processJsonResult( $jsonResult, $host );
|
||||||
$this->inputType == 'pmml' ||
|
|
||||||
$this->isValidMathML( $jsonResult->mml ) ) {
|
|
||||||
$xmlObject = new XmlTypeCheck( $jsonResult->svg, null, false );
|
|
||||||
if ( ! $xmlObject->wellFormed ) {
|
|
||||||
$this->lastError = $this->getError( 'math_invalidxml', $host );
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
$this->setSvg( $jsonResult->svg );
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ( property_exists( $jsonResult, 'log' ) ) {
|
if ( property_exists( $jsonResult, 'log' ) ) {
|
||||||
$log = $jsonResult->log;
|
$log = $jsonResult->log;
|
||||||
|
@ -457,4 +436,39 @@ class MathMathML extends MathRenderer {
|
||||||
parent::initializeFromDatabaseRow( $rpage );
|
parent::initializeFromDatabaseRow( $rpage );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue