[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Wed, 23 Mar 2005 22:02:32 -0000
albertel Wed Mar 23 17:02:32 2005 EDT
Modified files:
/loncom/xml lonxml.pm
Log:
- escape { and } for printing
- handle strings of special symbols more correctly
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.366 loncom/xml/lonxml.pm:1.367
--- loncom/xml/lonxml.pm:1.366 Thu Mar 17 08:56:32 2005
+++ loncom/xml/lonxml.pm Wed Mar 23 17:02:32 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.366 2005/03/17 13:56:32 albertel Exp $
+# $Id: lonxml.pm,v 1.367 2005/03/23 22:02:32 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -419,18 +419,17 @@
$string=~s/([^\\])\#/$1\\\#/g;
} else {
$string=~s/\\/\\ensuremath{\\backslash}/g;
- $string=~s/([^\\]|^)\%/$1\\\%/g;
- $string=~s/([^\\]|^)\$/$1\\\$/g;
- $string=~s/([^\\])\_/$1\\_/g;
- $string=~s/\$\$/\$\\\$/g;
- $string=~s/\_\_/\_\\\_/g;
- $string=~s/\#\#/\#\\\#/g;
+ $string=~s/\\\%|\%/\\\%/g;
+ $string=~s/\\{|{/\\{/g;
+ $string=~s/\\}|}/\\}/g;
+ $string=~s/\\\$|\$/\\\$/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;
+ $string=~s/\\\&|\&/\\\&/g;
+ $string=~s/\\\#|\#/\\\#/g;
$string=~s/\|/\$\\mid\$/g;
#single { or } How to escape?
}