--- loncom/xml/lonxml.pm 2003/10/27 19:00:11 1.288 +++ loncom/xml/lonxml.pm 2003/11/21 20:21:20 1.295 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.288 2003/10/27 19:00:11 sakharuk Exp $ +# $Id: lonxml.pm,v 1.295 2003/11/21 20:21:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -167,6 +167,9 @@ $Apache::lonxml::style_end_values=''; #should we do the postag variable interpolation $Apache::lonxml::post_evaluate=1; +#a header message to emit in the case of any generated warning or errors +$Apache::lonxml::warnings_error_header=''; + sub xmlbegin { my $output=''; if ($ENV{'browser.mathml'}) { @@ -337,6 +340,13 @@ sub xmlparse { &Apache::style::styleparser($target,$styletext)); } } + } elsif ($ENV{'construct.style'} && ($ENV{'request.state'} eq 'construct')) { + my $location=&Apache::lonnet::filelocation('',$ENV{'construct.style'}); + my $styletext=&Apache::lonnet::getfile($location); + if ($styletext ne '-1') { + %style_for_target = (%style_for_target, + &Apache::style::styleparser($target,$styletext)); + } } #&printalltags(); my @pars = (); @@ -397,7 +407,9 @@ sub latex_special_symbols { $string=~s/\\ /\\char92 /g; $string=~s/\^/\\\^ /g; $string=~s/\~/\\char126 /g; - $string=~s/(&[^A-Za-z\#])/\\$1/g; + #fixup & if it doesn't look like + # { or α + $string=~s/(&(?!((\#[0-9]+)|([a-z]+));))/\\$1/gi; $string=~s/([^&])\#/$1\\#/g; $string=~s/(\$|_|{|})/\\$1/g; $string=~s/\\char92 /\\texttt{\\char92}/g; @@ -616,6 +628,7 @@ sub setup_globals { @Apache::lonxml::extlinks=(); @Apache::lonxml::ssi_info=(); $Apache::lonxml::post_evaluate=1; + $Apache::lonxml::warnings_error_header=''; if ($target eq 'meta') { $Apache::lonxml::redirection = 0; $Apache::lonxml::metamode = 1; @@ -845,14 +858,12 @@ sub get_all_text_unbalanced { sub increment_counter { my ($increment) = @_; - if ($ENV{'form.freeze_counter'} ne 'yes') { - if (defined($increment) && $increment gt 0) { - $Apache::lonxml::counter+=$increment; - } else { - $Apache::lonxml::counter++; - } - $Apache::lonxml::counter_changed=1; + if (defined($increment) && $increment gt 0) { + $Apache::lonxml::counter+=$increment; + } else { + $Apache::lonxml::counter++; } + $Apache::lonxml::counter_changed=1; } sub init_counter { @@ -987,6 +998,7 @@ sub parstring { my $val=$token->[2]->{$_}; $val =~ s/([\%\@\\\"\'])/\\$1/g; #if ($val =~ m/^[\%\@]/) { $val="\\".$val; } + if ($val !~ m/^\s*\$[a-z_]/i) { $val =~ s/\$/\\\$/g; } $temp .= "my \$$_=\"$val\";"; } } @@ -1062,6 +1074,7 @@ ENDSCRIPT sub storefile { my ($file,$contents)=@_; + &Apache::lonnet::correct_line_ends(\$contents); if (my $fh=Apache::File->new('>'.$file)) { print $fh $contents; $fh->close(); @@ -1292,7 +1305,9 @@ sub error { $errorcount++; if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) { # If printing in construction space, put the error inside

-    print "ERROR:".join("\n",@_)."\n";
+      print $Apache::lonxml::warnings_error_header.
+	  "ERROR:".join("\n",@_)."\n";
+      $Apache::lonxml::warnings_error_header='';
   } else {
     print "An Error occured while processing this resource. The instructor has been notified. 
"; #notify author @@ -1315,13 +1330,15 @@ sub error { } sub warning { - $warningcount++; + $warningcount++; - if ($ENV{'form.grade_target'} ne 'tex') { - if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) { - print "WARNING:".join('
',@_)."
\n"; - } - } + if ($ENV{'form.grade_target'} ne 'tex') { + if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) { + print $Apache::lonxml::warnings_error_header. + "WARNING:".join('
',@_)."
\n"; + $Apache::lonxml::warnings_error_header=''; + } + } } sub get_param {