From 82a76d38b5e60bace4dc9aa9e552a03e256bd892 Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Wed, 10 Aug 2005 12:58:38 +0000 Subject: [PATCH] Some more tweaks to LaTeX filter - see bug #3829. --- filter/tex/filter.php | 9 +++++---- filter/tex/latex.php | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/filter/tex/filter.php b/filter/tex/filter.php index 591b5c2d86f..c29220ee253 100644 --- a/filter/tex/filter.php +++ b/filter/tex/filter.php @@ -88,7 +88,7 @@ function tex_filter ($courseid, $text) { global $CFG; /// Do a quick check using stripos to avoid unnecessary work - if (!preg_match('/ TeX expression // or $$ TeX expression $$ - // or \[ TeX expression \] // original tag of MathType and TeXaide (dlnsk) - preg_match_all('/(.+?)<\/tex>|\$\$(.+?)\$\$|\\\\\[(.+?)\\\\\]/is', $text, $matches); + // or \[ TeX expression \] // original tag of MathType and TeXaide (dlnsk) + // or [tex] TeX expression [/tex] // somtime it's more comfortable than (dlnsk) + preg_match_all('/(.+?)<\/tex>|\$\$(.+?)\$\$|\\\\\[(.+?)\\\\\]|\\[tex\\](.+?)\\[\/tex\\]/is', $text, $matches); for ($i=0; $i','',$texexp); $texexp = str_replace('','',$texexp); $texexp = str_replace('','',$texexp); diff --git a/filter/tex/latex.php b/filter/tex/latex.php index 3cffaa90a96..e9a65179fc1 100644 --- a/filter/tex/latex.php +++ b/filter/tex/latex.php @@ -51,7 +51,12 @@ $doc .= $CFG->filter_tex_latexpreamble; $doc .= "\\pagestyle{empty}\n"; $doc .= "\\begin{document}\n"; - $doc .= "$ {$formula} $\n"; +//dlnsk $doc .= "$ {$formula} $\n"; + if (preg_match("/^[[:space:]]*\\\\begin\\{(gather|align|alignat|multline).?\\}/i",$formula)) { + $doc .= "$formula\n"; + } else { + $doc .= "$ {$formula} $\n"; + } $doc .= "\\end{document}\n"; return $doc; }