[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 12 Jul 2002 16:37:38 -0000


albertel		Fri Jul 12 12:37:38 2002 EDT

  Modified files:              
    /loncom/xml	lonxml.pm londefdef.pm 
  Log:
  - Should handle <m>$a<b<x$</m> properly
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.179 loncom/xml/lonxml.pm:1.180
--- loncom/xml/lonxml.pm:1.179	Mon Jul  1 11:29:23 2002
+++ loncom/xml/lonxml.pm	Fri Jul 12 12:37:38 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.179 2002/07/01 15:29:23 matthew Exp $
+# $Id: lonxml.pm,v 1.180 2002/07/12 16:37:38 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -933,8 +933,34 @@
 #print "<br />e $Apache::lonxml::depth : $Apache::lonxml::olddepth : $token->[1] : $curdepth\n";
 }
 
-sub get_all_text {
+sub get_all_text_unbalanced {
+ my($tag,$pars)= @_;
+ my $token;
+ my $result='';
+ $tag='<'.$tag.'>';
+ while ($token = $$pars[-1]->get_token) {
+   if (($token->[0] eq 'T')||($token->[0] eq 'C')||($token->[0] eq 'D')) {
+     $result.=$token->[1];
+   } elsif ($token->[0] eq 'PI') {
+     $result.=$token->[2];
+   } elsif ($token->[0] eq 'S') {
+     $result.=$token->[4];
+   } elsif ($token->[0] eq 'E')  {
+     $result.=$token->[2];
+   }
+   if ($result =~ /(.*)$tag(.*)/) {
+     &Apache::lonxml::debug('Got a winner with leftovers ::'.$2);
+     &Apache::lonxml::debug('Result is :'.$1);
+     $result=$1;
+     my $redo=$tag.$2;
+     &Apache::lonxml::newparser($pars,\$redo);
+     last;
+   }
+ }
+ return $result
+}
 
+sub get_all_text {
  my($tag,$pars)= @_;
  my $depth=0;
  my $token;
@@ -1225,7 +1251,7 @@
 sub debug {
   if ($Apache::lonxml::debug eq 1) {
     $|=1;
-    print("DEBUG:".join('<br />',@_)."<br />\n");
+    print("DEBUG:".&HTML::Entities::encode($_[0])."<br />\n");
   }
 }
 
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.72 loncom/xml/londefdef.pm:1.73
--- loncom/xml/londefdef.pm:1.72	Thu Jul 11 16:05:44 2002
+++ loncom/xml/londefdef.pm	Fri Jul 12 12:37:38 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.72 2002/07/11 20:05:44 sakharuk Exp $
+# $Id: londefdef.pm,v 1.73 2002/07/12 16:37:38 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -74,7 +74,7 @@
   my $currentstring = '';
   if ($target eq 'web') {
     $Apache::lonxml::prevent_entity_encode++;
-    my $inside = &Apache::lonxml::get_all_text("/m",$$parser[-1]);
+    my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
     $inside ='\\documentstyle{article}'.$inside;
     &Apache::lonxml::debug("M is starting with:$inside:");
     my $eval=&Apache::lonxml::get_param('eval',$parstack,$safeeval);
@@ -90,7 +90,9 @@
     }
     #&Apache::lonxml::debug("M is ends with:$currentstring:");
   } elsif ($target eq 'tex') {
-    $currentstring = "";
+    $currentstring = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
+  } else {
+    my $inside = &Apache::lonxml::get_all_text_unbalanced("/m",$parser);
   }
   return $currentstring;
 }