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

sakharuk lon-capa-cvs@mail.lon-capa.org
Fri, 23 Aug 2002 19:10:32 -0000


sakharuk		Fri Aug 23 15:10:32 2002 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  Guy, I've done what you wanted with some corrections which are more suitable
  for few more comlicated cases (see furher - I'll commit).	
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.187 loncom/xml/lonxml.pm:1.188
--- loncom/xml/lonxml.pm:1.187	Wed Aug  7 09:58:38 2002
+++ loncom/xml/lonxml.pm	Fri Aug 23 15:10:32 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.187 2002/08/07 13:58:38 matthew Exp $
+# $Id: lonxml.pm,v 1.188 2002/08/23 19:10:32 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -539,6 +539,23 @@
     return $output;
 }
 
+sub latex_special_sumbols {
+    my ($current_token,$stack,$parstack)=@_;
+    my @temp_array = @$stack;
+    if ($temp_array[-1] ne 'tt') {
+	if ($current_token=~m/\^/) {$current_token=~s/\^/\\verb|\^|/g;}
+    } else {
+	if ($current_token=~m/\^/) {$current_token=~s/\^/}\\verb|\^|{/g;}
+    }
+    if ($current_token=~m/>/) {$current_token=~s/>/\$>\$/g;}
+    if ($current_token=~m/</) {$current_token=~s/</\$<\$/g;}
+    if ($current_token=~m/\d%/) {$current_token =~ s/%/\\%/g;}
+    if ($current_token=~m/\s%/) {$current_token =~ s/%/\\%/g;}
+
+#    $current_token = ' start='.$current_token.'=finish ';
+    return $current_token;
+}
+
 sub inner_xmlparse {
   my ($target,$stack,$parstack,$pars,$safeeval,$style_for_target)=@_;
   my $finaloutput = '';
@@ -549,18 +566,10 @@
       if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) {
 	if ($metamode<1) {
 	    if ($target eq 'tex') {
-		my @temp_array = @$stack;
-		if ($temp_array[-1] ne 'm') {
-		    if ($temp_array[-1] ne 'tt') {
-			if ($token->[1]=~m/\^/) {$token->[1]=~s/\^/\\verb|\^|/g;}
-		    } else {
-			if ($token->[1]=~m/\^/) {$token->[1]=~s/\^/}\\verb|\^|{/g;}
-		    }
-		    if ($token->[1]=~m/>/) {$token->[1]=~s/>/\$>\$/g;}
-		    if ($token->[1]=~m/</) {$token->[1]=~s/</\$<\$/g;}
-		}
+		$result.=&latex_special_sumbols($token->[1],$stack,$parstack);
+	    } else {
+		$result.=$token->[1];
 	    }
-	  $result.=$token->[1];
 	}
       } elsif ($token->[0] eq 'PI') {
 	if ($metamode<1) {