--- loncom/xml/lonxml.pm 2004/03/09 20:37:58 1.309 +++ loncom/xml/lonxml.pm 2004/03/12 17:26:29 1.310 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.309 2004/03/09 20:37:58 albertel Exp $ +# $Id: lonxml.pm,v 1.310 2004/03/12 17:26:29 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -404,20 +404,15 @@ sub latex_special_symbols { $string =~ s/(\$|%|\#|&|\{|\})/\\$1/g; $string =~ s/_/ /g; } else { - $string=~s/\\ /\\char92 /g; - $string=~s/\^/\\\^\\strut /g; - $string=~s/\~/\\char126 /g; - #fixup & if it doesn't look like - # { or α - $string=~s/(&(?!((\#[0-9]+)|([a-z][a-z0-9]*));))/\\$1/gi; - $string=~s/([^&\\])\#/$1\\#/g; - $string=~s/\#\#/\#\\#/g; - $string=~s/(\$|_|{|})/\\$1/g; - $string=~s/\\char92 /\\texttt{\\char92}/g; - $string=~s/(>|<)/\$$1\$/g; #more or less - if ($string=~m/\d%/) {$string =~ s/(\d)%/$1\\%/g;} #percent after digit - if ($string=~m/\s%/) {$string =~ s/(\s)%/$1\\%/g;} #percent after space - if ($string eq '%.') {$string = '\%.';} #percent at the end of statement + $string=~s/([^\\])\%/$1\\\%/g; + $string=~s/([^\\])(\$|_)/$1\\$2/g; + $string=~s/\$\$/\$\\\$/g; + $string=~s/([^\\])\&/$1\\\&/g; + $string=~s/([^\\])\#/$1\\\#/g; + $string=~s/\#\#/\#\\\#/g; + $string=~s/([^\\])(\~|\^)/$1\\$2\\strut /g; + $string=~s/(>|<)/\\ensuremath\{$1\}/g; #more or less +#single { or } How to escape? } return $string; } @@ -511,7 +506,7 @@ sub inner_xmlparse { if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { #Style file definitions should be correct if ($target eq 'tex' && ($Apache::lonxml::usestyle)) { - $result=&latex_special_symbols($result); + $result=&latex_special_symbols(&Apache::lonprintout::character_chart($result)); } }