--- loncom/xml/lonxml.pm 2002/09/04 03:57:18 1.190 +++ loncom/xml/lonxml.pm 2002/09/04 21:01:33 1.193 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.190 2002/09/04 03:57:18 albertel Exp $ +# $Id: lonxml.pm,v 1.193 2002/09/04 21:01:33 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -539,21 +539,19 @@ 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') { - 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;} #more - if ($current_token=~m/</) {$current_token=~s/</\$<\$/g;} #less - if ($current_token=~m/\d%/) {$current_token =~ s/%/\\%/g;} #percent after digit - if ($current_token=~m/\s%/) {$current_token =~ s/%/\\%/g;} #persent after space - - -# $current_token = ' start='.$current_token.'=finish '; + $current_token=~s/\\/\\char92 /g; + $current_token=~s/\^/\\char94 /g; + $current_token=~s/\~/\\char126 /g; + $current_token=~s/(&[^a-z#])/\\$1/g; + $current_token=~s/([^&]\#)/\\$1/g; + $current_token=~s/(\$|_|{|})/\\$1/g; + $current_token=~s/\\char92 /\\texttt{\\char92}/g; + $current_token=~s/>/\$>\$/g; #more + $current_token=~s/</\$<\$/g; #less + if ($current_token=~m/\d%/) {$current_token =~ s/(\d)%/$1\\%/g;} #percent after digit + if ($current_token=~m/\s%/) {$current_token =~ s/(\s)%/$1\\%/g;} #persent after space return $current_token; } @@ -567,7 +565,7 @@ sub inner_xmlparse { if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { if ($metamode<1) { my $text=$token->[1]; - if ($token->[0] eq 'C') { + if ($token->[0] eq 'C' && $target eq 'tex') { $text = '%'.$text; $text =~ s/[\n\r]//g; } @@ -636,7 +634,7 @@ sub inner_xmlparse { } if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { if ($target eq 'tex') { - $result=&latex_special_sumbols($result,$stack,$parstack); + $result=&latex_special_symbols($result,$stack,$parstack); } }