diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
commit | 9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch) | |
tree | 46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/Math.php | |
parent | 78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff) |
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/Math.php')
-rw-r--r-- | includes/Math.php | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/includes/Math.php b/includes/Math.php index 8cf9b8d8..0e136d5f 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -37,7 +37,8 @@ class MathRenderer { if( $this->mode == MW_MATH_SOURCE ) { # No need to render or parse anything more! - return ('$ '.htmlspecialchars( $this->tex ).' $'); + # New lines are replaced with spaces, which avoids confusing our parser (bugs 23190, 22818) + return ('<span class="tex">$ ' . str_replace( "\n", " ", htmlspecialchars( $this->tex ) ) . ' $</span>'); } if( $this->tex == '' ) { return; # bug 8372 @@ -55,7 +56,7 @@ class MathRenderer { } } - if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) { + if( !is_executable( $wgTexvc ) ) { return $this->_error( 'math_notexvc' ); } $cmd = $wgTexvc . ' ' . @@ -71,7 +72,7 @@ class MathRenderer { } wfDebug( "TeX: $cmd\n" ); - $contents = `$cmd`; + $contents = wfShellExec( $cmd ); wfDebug( "TeX output:\n $contents\n---\n" ); if (strlen($contents) == 0) { @@ -153,7 +154,10 @@ class MathRenderer { $hashpath = $this->_getHashPath(); if( !file_exists( $hashpath ) ) { - if( !@wfMkdirParents( $hashpath, 0755 ) ) { + wfSuppressWarnings(); + $ret = wfMkdirParents( $hashpath, 0755 ); + wfRestoreWarnings(); + if( !$ret ) { return $this->_error( 'math_bad_output' ); } } elseif( !is_dir( $hashpath ) || !is_writable( $hashpath ) ) { @@ -231,7 +235,9 @@ class MathRenderer { if( file_exists( $filename ) ) { if( filesize( $filename ) == 0 ) { // Some horrible error corrupted stuff :( - @unlink( $filename ); + wfSuppressWarnings(); + unlink( $filename ); + wfRestoreWarnings(); } else { return true; } @@ -241,7 +247,10 @@ class MathRenderer { $hashpath = $this->_getHashPath(); if( !file_exists( $hashpath ) ) { - if( !@wfMkdirParents( $hashpath, 0755 ) ) { + wfSuppressWarnings(); + $ret = wfMkdirParents( $hashpath, 0755 ); + wfRestoreWarnings(); + if( !$ret ) { return false; } } elseif( !is_dir( $hashpath ) || !is_writable( $hashpath ) ) { @@ -323,10 +332,10 @@ class MathRenderer { .'/'. substr($this->hash, 2, 1); } - public static function renderMath( $tex, $params=array() ) { - global $wgUser; + public static function renderMath( $tex, $params=array(), ParserOptions $parserOptions = null ) { $math = new MathRenderer( $tex, $params ); - $math->setOutputMode( $wgUser->getOption('math')); + if ( $parserOptions ) + $math->setOutputMode( $parserOptions->getMath() ); return $math->render(); } } |