--- loncom/xml/lonxml.pm 2004/03/19 22:06:53 1.312 +++ loncom/xml/lonxml.pm 2004/03/23 00:47:48 1.313 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.312 2004/03/19 22:06:53 albertel Exp $ +# $Id: lonxml.pm,v 1.313 2004/03/23 00:47:48 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -409,16 +409,16 @@ sub latex_special_symbols { $string=~s/([^\\])\#/$1\\\#/g; } else { $string=~s/\\/\\ensuremath{\\backslash}/g; - $string=~s/([^\\])\%/$1\\\%/g; - $string=~s/([^\\])(\$|_)/$1\\$2/g; + $string=~s/([^\\]|^)\%/$1\\\%/g; + $string=~s/([^\\]|^)(\$|_)/$1\\$2/g; $string=~s/\$\$/\$\\\$/g; $string=~s/\#\#/\#\\\#/g; - $string=~s/([^\\])(\~|\^)/$1\\$2\\strut /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; + $string=~s/([^\\]|^)\&/$1\\\&/g; + $string=~s/([^\\]|^)\#/$1\\\#/g; #single { or } How to escape? } return $string;