# Adds support for LaTeX-style style inline equations ($equation$) to mediawiki.
# After the patch is applied, and $equation$ are
# interpreted in the same way.
diff -Naurp mediawiki-1.5.6-orig/includes/Parser.php mediawiki-1.5.6-latex/includes/Parser.php
--- mediawiki-1.5.6-orig/includes/Parser.php 2006-01-18 06:42:17.000000000 +0100
+++ mediawiki-1.5.6-latex/includes/Parser.php 2006-02-09 16:49:14.000000000 +0100
@@ -42,6 +42,7 @@ define( 'OT_MSG' , 3 );
# -style tags. This should not be anything we
# may want to use in wikisyntax
define( 'STRIP_COMMENTS', 'HTMLCommentStrip' );
+define( 'LATEX_DELIM', 'LatexDelim' );
# Constants needed for external link processing
define( 'HTTP_PROTOCOLS', 'http:\/\/|https:\/\/' );
@@ -273,6 +274,9 @@ class Parser
if( $tag == STRIP_COMMENTS ) {
$start = '//';
+ } else if ( $tag == LATEX_DELIM ) {
+ $start = '/\$()/i';
+ $end = '/\$/i';
} else {
$start = "/<$tag(\\s+[^>]*|\\s*)>/i";
$end = "/<\\/$tag\\s*>/i";
@@ -339,6 +343,7 @@ class Parser
$html_content = array();
$nowiki_content = array();
$math_content = array();
+ $latex_content = array();
$pre_content = array();
$comment_content = array();
$ext_content = array();
@@ -384,6 +389,15 @@ class Parser
$math_content[$marker] = '';
}
}
+
+ $text = Parser::extractTags(LATEX_DELIM, $text, $latex_content, $uniq_prefix);
+ foreach( $latex_content as $marker => $content ){
+ if( $render ) {
+ $latex_content[$marker] = renderMath( $content );
+ } else {
+ $latex_content[$marker] = '$'.$content.'$';
+ }
+ }
}
# pre
@@ -435,7 +449,7 @@ class Parser
if ( $state ) {
$state['html'] = $state['html'] + $html_content;
$state['nowiki'] = $state['nowiki'] + $nowiki_content;
- $state['math'] = $state['math'] + $math_content;
+ $state['math'] = $state['math'] + $math_content + $latex_content;
$state['pre'] = $state['pre'] + $pre_content;
$state['comment'] = $state['comment'] + $comment_content;
$state['gallery'] = $state['gallery'] + $gallery_content;
@@ -449,7 +463,7 @@ class Parser
$state = array(
'html' => $html_content,
'nowiki' => $nowiki_content,
- 'math' => $math_content,
+ 'math' => $math_content + $latex_content,
'pre' => $pre_content,
'comment' => $comment_content,
'gallery' => $gallery_content,