From 1b71c53e1d16d88f566b781c1e93aef426a5e1ee Mon Sep 17 00:00:00 2001 From: fiedorow Date: Tue, 30 Mar 2004 17:11:56 +0000 Subject: [PATCH] Bug fix for incorrect handling of negatives in equations and inequalities --- filter/algebra/AlgParser.pm | 2 +- filter/algebra/algebradebug.php | 2 ++ filter/algebra/filter.php | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/filter/algebra/AlgParser.pm b/filter/algebra/AlgParser.pm index 4398293052..6ab1e7967a 100755 --- a/filter/algebra/AlgParser.pm +++ b/filter/algebra/AlgParser.pm @@ -42,7 +42,7 @@ $binoper1 = '[-+=><%!#]'; $openparen = '[{(\\[]'; $closeparen = '[})\\]]'; $varname = '[A-Za-z](?:_[0-9]+)?'; -$specialvalue = '(?:e|pi|da|db|dc|de|df|dg|dh|di|dj|dk|dl|dm|dn|do|dp|dq|dr|ds|dt|du|dv|dw|dx|dy|dz|infty|alpha|bita|gamma|zita|thita|iota|kappa|lambda|mu|nu|xi|rho|sigma|tau|phi|chi|psi|omega|zepslon|zdelta|xeta|zupslon)'; +$specialvalue = '(?:e|pi|da|db|dc|de|df|dg|dh|di|dj|dk|dl|dm|dn|do|dp|dq|dr|ds|dt|du|dv|dw|dx|dy|dz|infty|alpha|bita|gamma|zita|thita|iota|kappa|lambda|mu|nu|xi|rho|sigma|tau|phi|chi|psi|omega|zepslon|zdelta|xeta|zupslon|zeroplace)'; $numberplain = '(?:\d+(?:\.\d*)?|\.\d+)'; $numberE = '(?:' . $numberplain . 'E[-+]?\d+)'; $number = '(?:' . $numberE . '|' . $numberplain . ')'; diff --git a/filter/algebra/algebradebug.php b/filter/algebra/algebradebug.php index caff0f6311..c5af44fe18 100644 --- a/filter/algebra/algebradebug.php +++ b/filter/algebra/algebradebug.php @@ -74,6 +74,7 @@ function algebra2tex($algebra) { $algebra = str_replace('<>','#',$algebra); $algebra = str_replace('<=','%',$algebra); $algebra = str_replace('>=','!',$algebra); + $algebra = preg_replace('/([=><%!#] *)-/',"\$1 zeroplace -",$algebra); $algebra = str_replace('delta','zdelta',$algebra); $algebra = str_replace('beta','bita',$algebra); $algebra = str_replace('theta','thita',$algebra); @@ -95,6 +96,7 @@ function algebra2tex($algebra) { } function refineTeX($texexp) { + $texexp = str_replace('zeroplace','',$texexp); $texexp = str_replace('#','\not= ',$texexp); $texexp = str_replace('%','\leq ',$texexp); $texexp = str_replace('!','\geq ',$texexp); diff --git a/filter/algebra/filter.php b/filter/algebra/filter.php index c38cda28a0..81947657f2 100644 --- a/filter/algebra/filter.php +++ b/filter/algebra/filter.php @@ -150,6 +150,7 @@ function algebra_filter ($courseid, $text) { $algebra = str_replace('<>','#',$algebra); $algebra = str_replace('<=','%',$algebra); $algebra = str_replace('>=','!',$algebra); + $algebra = preg_replace('/([=><%!#] *)-/',"\$1 zeroplace -",$algebra); $algebra = str_replace('delta','zdelta',$algebra); $algebra = str_replace('beta','bita',$algebra); $algebra = str_replace('theta','thita',$algebra); @@ -169,6 +170,7 @@ function algebra_filter ($courseid, $text) { if (preg_match('/parsehilight/',$texexp)) { $text = str_replace( $matches[0][$i],"Syntax error: " . $texexp,$text); } else if ($texexp) { + $texexp = str_replace('zeroplace','',$texexp); $texexp = str_replace('#','\not= ',$texexp); $texexp = str_replace('%','\leq ',$texexp); $texexp = str_replace('!','\geq ',$texexp); -- 2.39.5