2012-10-27 14:30:50 +00:00
|
|
|
<?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
|
|
|
|
*/
|
2014-06-05 21:06:43 +00:00
|
|
|
function getHtmlOutput() {
|
2012-10-27 14:30:50 +00:00
|
|
|
# No need to render or parse anything more!
|
|
|
|
# New lines are replaced with spaces, which avoids confusing our parser (bugs 23190, 22818)
|
2014-03-17 06:14:02 +00:00
|
|
|
if ( $this->getMathStyle() == MW_MATHSTYLE_DISPLAY ) {
|
|
|
|
$class = 'mwe-math-fallback-source-display';
|
|
|
|
} else {
|
|
|
|
$class = 'mwe-math-fallback-source-inline';
|
|
|
|
}
|
2012-10-27 14:30:50 +00:00
|
|
|
return Xml::element( 'span',
|
|
|
|
$this->getAttributes(
|
|
|
|
'span',
|
|
|
|
array(
|
2014-03-17 06:14:02 +00:00
|
|
|
// the former class name was 'tex'
|
|
|
|
// for backwards compatibility we keep this classname
|
|
|
|
'class' => $class. ' tex',
|
2012-10-27 14:30:50 +00:00
|
|
|
'dir' => 'ltr'
|
|
|
|
)
|
|
|
|
),
|
2013-04-25 17:07:25 +00:00
|
|
|
'$ ' . str_replace( "\n", " ", $this->getTex() ) . ' $'
|
2012-10-27 14:30:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-05-27 04:46:53 +00:00
|
|
|
protected function getMathTableName() {
|
|
|
|
throw new MWException ( 'in math source mode no database caching should happen');
|
|
|
|
}
|
2014-06-05 21:06:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* No rendering required in plain text mode
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
function render() {
|
2014-06-05 21:06:43 +00:00
|
|
|
// assume unchanged to avoid unnecessary database access
|
|
|
|
$this->changed = false;
|
|
|
|
return true;
|
2014-06-05 21:06:43 +00:00
|
|
|
}
|
2012-10-27 14:30:50 +00:00
|
|
|
}
|