--- loncom/xml/lonxml.pm 2005/03/10 19:10:31 1.362
+++ loncom/xml/lonxml.pm 2005/04/01 18:08:14 1.369
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.362 2005/03/10 19:10:31 matthew Exp $
+# $Id: lonxml.pm,v 1.369 2005/04/01 18:08:14 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -174,7 +174,8 @@ sub xmlend {
my ($target,$parser)=@_;
my $mode='xml';
my $status='OPEN';
- if ($Apache::lonhomework::parsing_a_problem) {
+ if ($Apache::lonhomework::parsing_a_problem ||
+ $Apache::lonhomework::parsing_a_task ) {
$mode='problem';
$status=$Apache::inputtags::status[-1];
}
@@ -419,18 +420,17 @@ sub latex_special_symbols {
$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?
}
@@ -700,6 +700,7 @@ sub init_safespace {
$safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
$safehole->wrap(\&Apache::chemresponse::chem_standard_order,$safeeval,
'&chem_standard_order');
+ $safehole->wrap(\&Apache::response::check_status,$safeeval,'&check_status');
$safehole->wrap(\&Math::Cephes::asin,$safeeval,'&asin');
$safehole->wrap(\&Math::Cephes::acos,$safeeval,'&acos');
@@ -1056,7 +1057,8 @@ sub get_all_text {
sub newparser {
my ($parser,$contentref,$dir) = @_;
push (@$parser,HTML::LCParser->new($contentref));
- $$parser['-1']->xml_mode('1');
+ $$parser[-1]->xml_mode(1);
+ $$parser[-1]->marked_sections(1);
if ( $dir eq '' ) {
push (@Apache::lonxml::pwd, $Apache::lonxml::pwd[$#Apache::lonxml::pwd]);
} else {
@@ -1251,7 +1253,7 @@ $initialize
$xml_help
$buttons
-
+
$buttons
@@ -1297,14 +1299,12 @@ sub handler {
$Apache::lonxml::debug=$ENV{'user.debug'};
- if ($ENV{'browser.mathml'}) {
- &Apache::loncommon::content_type($request,'text/xml');
- } else {
- &Apache::loncommon::content_type($request,'text/html');
- }
+ &Apache::loncommon::content_type($request,'text/html');
&Apache::loncommon::no_cache($request);
- $request->set_last_modified(&Apache::lonnet::metadata($request->uri,
- 'lastrevisiondate'));
+ if ($ENV{'request.state'} eq 'published') {
+ $request->set_last_modified(&Apache::lonnet::metadata($request->uri,
+ 'lastrevisiondate'));
+ }
$request->send_http_header;
return OK if $request->header_only;
@@ -1372,6 +1372,7 @@ ENDNOTFOUND
if (!$ENV{'form.editmode'} || $ENV{'form.viewmode'}) {
$result = &Apache::lonxml::xmlparse($request,$target,$filecontents,
'',%mystyle);
+ undef($Apache::lonhomework::parsing_a_task);
}
}