Merge "LaTeXML: prevent automatic rerendering of SVG"
This commit is contained in:
commit
a24f16d79e
@ -178,7 +178,7 @@ class MathLaTeXML extends MathMathML {
|
|||||||
* No cache is used.
|
* No cache is used.
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function calulateSvg() {
|
public function calculateSvg() {
|
||||||
$renderer = new MathMathML( $this->getTex() );
|
$renderer = new MathMathML( $this->getTex() );
|
||||||
$renderer->setMathml( $this->getMathml() );
|
$renderer->setMathml( $this->getMathml() );
|
||||||
$renderer->setMode( MW_MATH_LATEXML );
|
$renderer->setMode( MW_MATH_LATEXML );
|
||||||
@ -192,16 +192,22 @@ class MathLaTeXML extends MathMathML {
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the SVG image
|
* Gets the SVG image
|
||||||
* Lazy evaluation: If no SVG image exists it's generated on the fly
|
*
|
||||||
|
* @param string $render if set to 'render' (default) and no SVG image exists, the function
|
||||||
|
* tries to generate it on the fly.
|
||||||
|
* Otherwise, if set to 'cached', and there is no SVG in the database
|
||||||
|
* cache, an empty string is returned.
|
||||||
|
*
|
||||||
* @return string XML-Document of the rendered SVG
|
* @return string XML-Document of the rendered SVG
|
||||||
*/
|
*/
|
||||||
public function getSvg() {
|
public function getSvg( $render = 'render' ) {
|
||||||
if ( $this->isPurge() || $this->svg == '' ) {
|
if ( $render == 'render' && ( $this->isPurge() || $this->svg == '' ) ) {
|
||||||
$this->calulateSvg();
|
$this->calculateSvg();
|
||||||
}
|
}
|
||||||
return $this->svg;
|
return parent::getSvg( $render );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getMathTableName() {
|
protected function getMathTableName() {
|
||||||
|
@ -107,7 +107,7 @@ class MathMathML extends MathRenderer {
|
|||||||
if ( $dbres ) {
|
if ( $dbres ) {
|
||||||
if ( $this->isValidMathML( $this->getMathml() ) ) {
|
if ( $this->isValidMathML( $this->getMathml() ) ) {
|
||||||
wfDebugLog( 'Math', 'Valid MathML entry found in database.' );
|
wfDebugLog( 'Math', 'Valid MathML entry found in database.' );
|
||||||
if ( $this->getSvg() ) {
|
if ( $this->getSvg( 'cached' ) ) {
|
||||||
wfDebugLog( 'Math', 'SVG-fallback found in database.' );
|
wfDebugLog( 'Math', 'SVG-fallback found in database.' );
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -671,10 +671,16 @@ abstract class MathRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the SVG image
|
||||||
*
|
*
|
||||||
* @return type
|
* @param string $render if set to 'render' (default) and no SVG image exists, the function
|
||||||
|
* tries to generate it on the fly.
|
||||||
|
* Otherwise, if set to 'cached', and there is no SVG in the database
|
||||||
|
* cache, an empty string is returned.
|
||||||
|
*
|
||||||
|
* @return string XML-Document of the rendered SVG
|
||||||
*/
|
*/
|
||||||
public function getSvg() {
|
public function getSvg( $render = 'render' ) {
|
||||||
// Spaces will prevent the image from being displayed correctly in the browser
|
// Spaces will prevent the image from being displayed correctly in the browser
|
||||||
return trim( $this->svg );
|
return trim( $this->svg );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user