[LON-CAPA-cvs] cvs: loncom /interface lonhtmlgateway.pm /xml lontexconvert.pm scripttag.pm

faziophi faziophi@source.lon-capa.org
Tue, 27 Apr 2010 20:29:25 -0000


faziophi		Tue Apr 27 20:29:25 2010 EDT

  Modified files:              
    /loncom/xml	scripttag.pm lontexconvert.pm 
    /loncom/interface	lonhtmlgateway.pm 
  Log:
  Making &init_tth() optional when calling lontexconvert::algebra, by adding
  an extra argument, and then updating the two places where this function
  is called.
  
  
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.151 loncom/xml/scripttag.pm:1.152
--- loncom/xml/scripttag.pm:1.151	Thu Dec 11 21:28:59 2008
+++ loncom/xml/scripttag.pm	Tue Apr 27 20:29:20 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.151 2008/12/11 21:28:59 raeburn Exp $
+# $Id: scripttag.pm,v 1.152 2010/04/27 20:29:20 faziophi Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -597,7 +597,7 @@
 	$inside = &Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
 	if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
 	    my $style=&Apache::lonxml::get_param('style',$parstack,$safeeval);
-	    $result=&Apache::lontexconvert::algebra($inside,$target,$style,$parstack,$safeeval);
+	    $result=&Apache::lontexconvert::algebra($inside,undef,$target,$style,$parstack,$safeeval);
 	}
 	$Apache::lonxml::post_evaluate=0;
     }
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.102 loncom/xml/lontexconvert.pm:1.103
--- loncom/xml/lontexconvert.pm:1.102	Mon Apr 26 21:36:50 2010
+++ loncom/xml/lontexconvert.pm	Tue Apr 27 20:29:20 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Conversion Module
 #
-# $Id: lontexconvert.pm,v 1.102 2010/04/26 21:36:50 faziophi Exp $
+# $Id: lontexconvert.pm,v 1.103 2010/04/27 20:29:20 faziophi Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -394,15 +394,16 @@
     foreach my $fragment (split(/(?:\&lt\;|\<)\/*algebra\s*(?:\&gt\;|\>)/i,
 				$message)) {
 	if ($tex) {
+        my $algebra = &algebra($fragment, 'web', undef, undef, undef, undef, 'tth');
 	    if ($email) {
-		$outmessage.='</pre><tt>'.&algebra($fragment,'web').'</tt><pre>';
+		$outmessage.='</pre><tt>'.$algebra.'</tt><pre>';
 		$tex=0;
 	    } else {
-		$outmessage.=&algebra($fragment,'web');
+		$outmessage.=$algebra;
 		$tex=0;
 	    }
 	} else {
-            $outmessage.=$fragment;
+        $outmessage.=$fragment;
 	    $tex=1;
 	}
     }
@@ -415,9 +416,9 @@
 
 sub algebra {
     use AlgParser;
-    &init_tth();
-    my ($string,$target,$style,$parstack,$safeeval)=@_;
+    my ($string,$target,$style,$parstack,$safeeval,$tth)=@_;
     my $parser = new AlgParserWithImplicitExpand;
+    if ($tth eq 'tth') {&init_tth();}
     $string=&prepare_algebra($string);
     my $ret = $parser->parse($string);
     my $result='['.&mt('Algebra unconverted due to previous errors').']';
Index: loncom/interface/lonhtmlgateway.pm
diff -u loncom/interface/lonhtmlgateway.pm:1.2 loncom/interface/lonhtmlgateway.pm:1.3
--- loncom/interface/lonhtmlgateway.pm:1.2	Tue Apr 27 17:07:35 2010
+++ loncom/interface/lonhtmlgateway.pm	Tue Apr 27 20:29:25 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # gateway for html input/output to be properly parsed and handled
 #
-# $Id: lonhtmlgateway.pm,v 1.2 2010/04/27 17:07:35 faziophi Exp $
+# $Id: lonhtmlgateway.pm,v 1.3 2010/04/27 20:29:25 faziophi Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -545,8 +545,12 @@
     my $parser = HTML::LCParser->new(\$input);
     while (my $token = $parser->get_token()) {
     	if ($token->[0] eq 'T') {
-    	    $output .= $token->[1];
-    	} elsif ($token->[0] eq 'D' || $token->[0] eq 'C') {
+            if ($self->{target} ne 'tex') {
+    	        $output .= &Apache::lontexconvert::smiley($token->[1]);
+    	    } else {
+                $output .= $token->[1];
+            }
+        } elsif ($token->[0] eq 'D' || $token->[0] eq 'C') {
     	    $output .= $token->[1];
     	} elsif ($token->[0] eq 'PI' || $token->[0] eq 'E') {
     	    $output .= $token->[2];
@@ -712,7 +716,7 @@
     # decoding it first. we also just get the tex, and
     # feed it through as if it were an <mi> tag.
     $input = &HTML::Entities::decode($input);
-    my $algebra = &Apache::lontexconvert::algebra($input, 'tex');
+    my $algebra = &Apache::lontexconvert::algebra($input, 'tth', 'tex');
     return &parse_m_tag($self, $algebra);
 }
 
@@ -802,7 +806,7 @@
 
 =head1 VERSION
 
-$Id: lonhtmlgateway.pm,v 1.2 2010/04/27 17:07:35 faziophi Exp $
+$Id: lonhtmlgateway.pm,v 1.3 2010/04/27 20:29:25 faziophi Exp $
 
 =cut