diff --git a/filter/tex/latex.php b/filter/tex/latex.php index e09f7e99bfd..9e7f897c673 100644 --- a/filter/tex/latex.php +++ b/filter/tex/latex.php @@ -114,11 +114,14 @@ $convertformat = 'png'; } $filename = str_replace(".{$convertformat}", '', $filename); - $tex = "{$this->temp_dir}/$filename.tex"; + $tex = "$filename.tex"; // Absolute paths won't work with openin_any = p setting. $dvi = "{$this->temp_dir}/$filename.dvi"; $ps = "{$this->temp_dir}/$filename.ps"; $img = "{$this->temp_dir}/$filename.{$convertformat}"; + // Change directory to temp dir so that we can work with relative paths. + chdir($this->temp_dir); + // turn the latex doc into a .tex file in the temp area $fh = fopen( $tex, 'w' ); fputs( $fh, $doc ); @@ -126,7 +129,7 @@ // run latex on document $command = "$pathlatex --interaction=nonstopmode --halt-on-error $tex"; - chdir( $this->temp_dir ); + if ($this->execute($command, $log)) { // It allways False on Windows // return false; } diff --git a/filter/tex/texdebug.php b/filter/tex/texdebug.php index dadbe186183..36808f1b928 100644 --- a/filter/tex/texdebug.php +++ b/filter/tex/texdebug.php @@ -238,12 +238,15 @@ $output .= "

base filename for expression is '$md5'

\n"; // temporary paths - $tex = "$latex->temp_dir/$md5.tex"; + $tex = "$md5.tex"; // Absolute paths won't work with openin_any = p setting. $dvi = "$latex->temp_dir/$md5.dvi"; $ps = "$latex->temp_dir/$md5.ps"; $convertformat = get_config('filter_tex', 'convertformat'); $img = "$latex->temp_dir/$md5.{$convertformat}"; + // Change directory to temp dir so that we can work with relative paths. + chdir($latex->temp_dir); + // put the expression as a file into the temp area $expression = html_entity_decode($expression); $output .= "

Processing TeX expression:

$expression
\n"; @@ -252,9 +255,6 @@ fputs($fh, $doc); fclose($fh); - // cd to temp dir - chdir($latex->temp_dir); - // step 1: latex command $pathlatex = escapeshellarg($pathlatex); $cmd = "$pathlatex --interaction=nonstopmode --halt-on-error $tex";