[LON-CAPA-cvs] cvs: modules /TexConvert/algebra AlgParser.pm loncom/xml lontexconvert.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 24 Feb 2005 09:06:14 -0000


albertel		Thu Feb 24 04:06:14 2005 EDT

  Modified files:              
    /loncom/xml	lontexconvert.pm 
    /modules/TexConvert/algebra	AlgParser.pm 
  Log:
  - remove some commented out code
  - move the geq leq not= transformations back into AlgParse.pm
  
  
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.49 loncom/xml/lontexconvert.pm:1.50
--- loncom/xml/lontexconvert.pm:1.49	Thu Feb 24 03:32:11 2005
+++ loncom/xml/lontexconvert.pm	Thu Feb 24 04:06:14 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Conversion Module
 #
-# $Id: lontexconvert.pm,v 1.49 2005/02/24 08:32:11 albertel Exp $
+# $Id: lontexconvert.pm,v 1.50 2005/02/24 09:06:14 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -221,7 +221,7 @@
     my $ret = $parser->parse($string);
     my $result='['.&mt('Algebra unconverted due to previous errors').']';
     if ( ref($ret) ) {
-	$parser->tostring();
+	#$parser->tostring();
 	$parser->normalize();
 	my $latex=$parser->tolatex();
 	$latex=&postprocess_algebra($latex);
@@ -239,12 +239,7 @@
 sub prepare_algebra {
     my ($string)=@_;
 
-    # change some multi character operators into single character operators
-    $string =~ s/<>/\#/g;
-    $string =~ s/<\=/\%/g;
-    $string =~ s/>\=/\!/g;
-    
-    # makes the decision about what is a minus sign easier
+    # makes the decision about what is a minus sign easier supposedly
     $string =~ s/([\=\>\<\%\!\#] *)-/$1 zeroplace -/g;
 
     return $string;
@@ -253,10 +248,10 @@
 sub postprocess_algebra {
     my ($string)=@_;
     
-    # exapnd out some operators
-    $string =~ s/\#/\\not= /g;
-    $string =~ s/\%/\\leq /g;
-    $string =~ s/\!/\\geq /g;
+    # moodle had these and I don't know why, ignoring them for now
+    # $string =~/\\left\{/\{/g;
+    # $string =~/\\right\}/\}/g;
+    # $string =~/\\fun/ /g;
 
     return $string;
 }
Index: modules/TexConvert/algebra/AlgParser.pm
diff -u modules/TexConvert/algebra/AlgParser.pm:1.8 modules/TexConvert/algebra/AlgParser.pm:1.9
--- modules/TexConvert/algebra/AlgParser.pm:1.8	Thu Feb 24 03:34:52 2005
+++ modules/TexConvert/algebra/AlgParser.pm	Thu Feb 24 04:06:14 2005
@@ -39,7 +39,7 @@
 
 my $binoper3 = '(?:\\^|\\*\\*)';
 my $binoper2 = '[/*_,]';
-my $binoper1 = '[-+=><%!#]';
+my $binoper1 = '(?:<>|<=|>=|[-+=><%!])';
 my $openparen = '[{(\\[]';
 my $closeparen = '[})\\]]';
 my $varname = '[A-Za-z](?:_[0-9]+)?';
@@ -534,7 +534,11 @@
   /binop1/ && do {
     my ($p1, $p2) = ('','');
     if ($args[2]->[0] eq 'binop1') {($p1,$p2)=qw{ \left( \right) };}
-    return ($args[1]->tolatex() . $args[0] . $p1 .
+    my $cmd=$args[0];
+    if    ($args[0] eq '<>') { $cmd='\\not= '; }
+    elsif ($args[0] eq '<=') { $cmd='\\leq ';  }
+    elsif ($args[0] eq '>=') { $cmd='\\geq ';  }
+    return ($args[1]->tolatex() . $cmd . $p1 .
             $args[2]->tolatex() . $p2);
   };
   /unop1/ && do {
@@ -566,8 +570,6 @@
                '{' . $args[2]->tolatex() . '}' ); 
     }
     elsif ($args[0] eq '*'){
-#	return('\frac{' . $p1 . $args[1]->tolatex() . $p2 . '}'.
-#               '{' . $p3 . $args[2]->tolatex() . $p4 . '}' );
 	return($args[1]->tolatex() . '\cdot ' . $args[2]->tolatex() ); 
     }
     else{
@@ -626,7 +628,6 @@
   };
   /closep/ && do {
     my($backslash) = '';
-    my(%close) = %AlgParser::close;
     if ($args[0] eq '{') {$backslash = '\\';}
 #This is for editors to match: }
     return ('\left' . $backslash . $args[0] . $args[1]->tolatex() .