mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-24 23:46:39 +00:00
65642489ae
Currently the method render always returns a html string that can be a string that represents the correct result or a rendered error message. This change splits rendering and fetching of the HTML output. This simplifies the logic of the rendering and caching mechanism. Now the render method returns a boolean that indicates if the rendering was sucessful or not. Step 2/2 Warning: Errors in this change might affect caching logic and squid caches. Change-Id: I00502b84212ed70cdf63bd69916a35afbd6fdbc1
63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* MediaWiki math extension
|
|
*
|
|
* (c) 2002-2012 Tomasz Wegrzanowski, Brion Vibber, Moritz Schubotz and other MediaWiki contributors
|
|
* GPLv2 license; info in main package.
|
|
*
|
|
* Contains everything related to <math> </math> parsing
|
|
* @file
|
|
*/
|
|
|
|
|
|
/**
|
|
* Takes LaTeX fragments and outputs the source directly to the browser
|
|
*
|
|
* @author Tomasz Wegrzanowski
|
|
* @author Brion Vibber
|
|
* @author Moritz Schubotz
|
|
* @ingroup Parser
|
|
*/
|
|
class MathSource extends MathRenderer {
|
|
/**
|
|
* Renders TeX by outputting it to the browser in a span tag
|
|
*
|
|
* @return string span tag with TeX
|
|
*/
|
|
function getHtmlOutput() {
|
|
# No need to render or parse anything more!
|
|
# New lines are replaced with spaces, which avoids confusing our parser (bugs 23190, 22818)
|
|
if ( $this->getMathStyle() == MW_MATHSTYLE_DISPLAY ) {
|
|
$class = 'mwe-math-fallback-source-display';
|
|
} else {
|
|
$class = 'mwe-math-fallback-source-inline';
|
|
}
|
|
return Xml::element( 'span',
|
|
$this->getAttributes(
|
|
'span',
|
|
array(
|
|
// the former class name was 'tex'
|
|
// for backwards compatibility we keep this classname
|
|
'class' => $class. ' tex',
|
|
'dir' => 'ltr'
|
|
)
|
|
),
|
|
'$ ' . str_replace( "\n", " ", $this->getTex() ) . ' $'
|
|
);
|
|
}
|
|
|
|
protected function getMathTableName() {
|
|
throw new MWException ( 'in math source mode no database caching should happen');
|
|
}
|
|
|
|
/**
|
|
* No rendering required in plain text mode
|
|
* @return boolean
|
|
*/
|
|
function render() {
|
|
// assume unchanged to avoid unnecessary database access
|
|
$this->changed = false;
|
|
return true;
|
|
}
|
|
}
|