--- loncom/xml/lonxml.pm 2002/08/23 19:10:32 1.188 +++ loncom/xml/lonxml.pm 2002/09/04 04:55:13 1.191 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.188 2002/08/23 19:10:32 sakharuk Exp $ +# $Id: lonxml.pm,v 1.191 2002/09/04 04:55:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -539,7 +539,7 @@ sub htmlclean { return $output; } -sub latex_special_sumbols { +sub latex_special_symbols { my ($current_token,$stack,$parstack)=@_; my @temp_array = @$stack; if ($temp_array[-1] ne 'tt') { @@ -547,10 +547,11 @@ sub latex_special_sumbols { } 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;} #more + if ($current_token=~m/get_token) { if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { if ($metamode<1) { - if ($target eq 'tex') { - $result.=&latex_special_sumbols($token->[1],$stack,$parstack); - } else { - $result.=$token->[1]; + my $text=$token->[1]; + if ($token->[0] eq 'C') { + $text = '%'.$text; + $text =~ s/[\n\r]//g; } + $result.=$text; } } elsif ($token->[0] eq 'PI') { if ($metamode<1) { @@ -632,6 +634,12 @@ sub inner_xmlparse { $result= &Apache::run::evaluate($result,$safeeval,''); } } + if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { + if ($target eq 'tex') { + $result=&latex_special_symbols($result,$stack,$parstack); + } + } + # Encode any high ASCII characters if (!$Apache::lonxml::prevent_entity_encode) { $result=&HTML::Entities::encode($result,"\200-\377"); @@ -758,13 +766,13 @@ sub callsub { } if (!$deleted) { if ($space) { - #&Apache::lonxml::debug("Calling sub $sub in $space $metamode"); + &Apache::lonxml::debug("Calling sub $sub in $space $metamode"); $sub1="$space\:\:$sub"; ($currentstring,$nodefault) = &$sub1($target,$token,$tagstack, $parstack,$parser,$safeeval, $style); } else { - #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode"); + &Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode"); if ($metamode <1) { if (defined($token->[4]) && ($metamode < 1)) { $currentstring = $token->[4]; @@ -957,6 +965,7 @@ sub decreasedepth { } sub get_all_text_unbalanced { +#there is a copy of this in lonpublisher.pm my($tag,$pars)= @_; my $token; my $result='';