--- loncom/xml/lonxml.pm 2004/03/12 17:26:29 1.310 +++ loncom/xml/lonxml.pm 2004/03/19 22:01:13 1.311 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.310 2004/03/12 17:26:29 sakharuk Exp $ +# $Id: lonxml.pm,v 1.311 2004/03/19 22:01:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -401,17 +401,23 @@ sub latex_special_symbols { my ($string,$where)=@_; if ($where eq 'header') { $string =~ s/(\\|_|\^)/ /g; - $string =~ s/(\$|%|\#|&|\{|\})/\\$1/g; + $string =~ s/(\$|%|\{|\})/\\$1/g; $string =~ s/_/ /g; + $string=&Apache::lonprintout::character_chart($string); + # any & or # leftover should be safe to just escape + $string=~s/([^\\])\&/$1\\\&/g; + $string=~s/([^\\])\#/$1\\\#/g; } else { $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 + $string=&Apache::lonprintout::character_chart($string); + # any & or # leftover should be safe to just escape + $string=~s/([^\\])\&/$1\\\&/g; + $string=~s/([^\\])\#/$1\\\#/g; #single { or } How to escape? } return $string; @@ -506,7 +512,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(&Apache::lonprintout::character_chart($result)); + $result=&latex_special_symbols($result); } } @@ -746,6 +752,7 @@ sub init_safespace { $safehole->wrap(\&Math::Random::random_get_seed,$safeeval,'&random_get_seed'); $safehole->wrap(\&Math::Random::random_set_seed,$safeeval,'&random_set_seed'); $safehole->wrap(\&Apache::lonxml::error,$safeeval,'&LONCAPA_INTERNAL_ERROR'); + $safehole->wrap(\&Apache::lonxml::debug,$safeeval,'&LONCAPA_INTERNAL_DEBUG'); #need to inspect this class of ops # $safeeval->deny(":base_orig");