--- loncom/xml/lonxml.pm 2002/07/15 19:45:18 1.181
+++ loncom/xml/lonxml.pm 2002/09/04 06:55:27 1.192
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.181 2002/07/15 19:45:18 www Exp $
+# $Id: lonxml.pm,v 1.192 2002/09/04 06:55:27 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -176,6 +176,7 @@ sub xmlend {
unless (($hidden) && (!$seeid)) {
my $message=$contrib{$idx.':message'};
$message=~s/\n/\
/g;
+ $message=&Apache::lontexconvert::msgtexconverted($message);
if ($message) {
if ($hidden) {
$message=''.$message.'';
@@ -332,7 +333,8 @@ sub registerurl {
my $target = shift;
my $result = '';
if ($target eq 'edit') {
- $result .="\n";
}
@@ -384,7 +386,7 @@ ENDPARM
menu.switchbutton
(8,1,'eval.gif','evaluate','this','gopost("/adm/evaluate",currentURL)');
menu.switchbutton
- (8,2,'fdbk.gif','feedback','on this','gopost("/adm/feedback",currentURL)');
+ (8,2,'fdbk.gif','feedback','discuss','gopost("/adm/feedback",currentURL)');
menu.switchbutton
(8,3,'prt.gif','prepare','printout','gopost("/adm/printout",currentURL)');
menu.switchbutton
@@ -537,6 +539,22 @@ sub htmlclean {
return $output;
}
+sub latex_special_symbols {
+ my ($current_token,$stack,$parstack)=@_;
+ $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;
+}
+
sub inner_xmlparse {
my ($target,$stack,$parstack,$pars,$safeeval,$style_for_target)=@_;
my $finaloutput = '';
@@ -546,7 +564,12 @@ sub inner_xmlparse {
while ($token = $$pars['-1']->get_token) {
if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) {
if ($metamode<1) {
- $result=$token->[1];
+ my $text=$token->[1];
+ if ($token->[0] eq 'C') {
+ $text = '%'.$text;
+ $text =~ s/[\n\r]//g;
+ }
+ $result.=$text;
}
} elsif ($token->[0] eq 'PI') {
if ($metamode<1) {
@@ -609,6 +632,12 @@ sub inner_xmlparse {
$result= &Apache::run::evaluate($result,$safeeval,'');
}
}
+ if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) {
+ if ($target eq 'tex') {
+ $result=&latex_special_symbols($result,$stack,$parstack);
+ }
+ }
+
# Encode any high ASCII characters
if (!$Apache::lonxml::prevent_entity_encode) {
$result=&HTML::Entities::encode($result,"\200-\377");
@@ -735,13 +764,13 @@ sub callsub {
}
if (!$deleted) {
if ($space) {
- #&Apache::lonxml::debug("Calling sub $sub in $space $metamode");
+ &Apache::lonxml::debug("Calling sub $sub in $space $metamode");
$sub1="$space\:\:$sub";
($currentstring,$nodefault) = &$sub1($target,$token,$tagstack,
$parstack,$parser,$safeeval,
$style);
} else {
- #&Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode");
+ &Apache::lonxml::debug("NOT Calling sub $sub in $space $metamode");
if ($metamode <1) {
if (defined($token->[4]) && ($metamode < 1)) {
$currentstring = $token->[4];
@@ -934,6 +963,7 @@ sub decreasedepth {
}
sub get_all_text_unbalanced {
+#there is a copy of this in lonpublisher.pm
my($tag,$pars)= @_;
my $token;
my $result='';