mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-24 07:34:22 +00:00
c5b0b15d8f
* Removes the MathJax heuristics that decides if equations are centered or left-aligned. * Introduces the attribute display to specify if the math element is rendered in inline, display, or inline-displaystyle. * add css rules for display / inline math images Bug: 61051 Change-Id: Iba69903f781f0cb1606b8ddcffb90fb86c9b229b
50 lines
1.2 KiB
PHP
50 lines
1.2 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 render() {
|
|
# 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() ) . ' $'
|
|
);
|
|
}
|
|
|
|
}
|