--- loncom/xml/lonxml.pm 2005/04/07 06:56:27 1.372
+++ loncom/xml/lonxml.pm 2005/06/24 21:09:31 1.378
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.372 2005/04/07 06:56:27 albertel Exp $
+# $Id: lonxml.pm,v 1.378 2005/06/24 21:09:31 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -382,33 +382,6 @@ sub xmlparse {
return $finaloutput;
}
-sub htmlclean {
- my ($raw,$full)=@_;
-# Take care of CRLF etc
-
- $raw=~s/\r\f/\n/gs; $raw=~s/\f\r/\n/gs;
- $raw=~s/\r\n/\n/gs; $raw=~s/\n\r/\n/gs;
- $raw=~s/\f/\n/gs; $raw=~s/\r/\n/gs;
- $raw=~s/\&\#10\;/\n/gs; $raw=~s/\&\#13\;/\n/gs;
-
-# Generate empty tags, remove wrong end tags
- $raw=~s/\<(br|hr|img|meta|allow|basefont)([^\>\/]*?)\>/\<$1$2 \/\>/gis;
- $raw=~s/\<\/(br|hr|img|meta|allow|basefont)\>//gis;
- unless ($full) {
- $raw=~s/\<[\/]*(body|head|html)\>//gis;
- }
-# Make standard tags lowercase
- foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m',
- 'table','tr','td','th','p','br','hr','img','embed','font',
- 'a','strong','center','title','basefont','li','ol','ul',
- 'input','select','form','option','script','pre') {
- $raw=~s/\<$_\s*\>/\<$_\>/gis;
- $raw=~s/\<\/$_\s*\>/<\/$_\>/gis;
- $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis;
- }
- return $raw;
-}
-
sub latex_special_symbols {
my ($string,$where)=@_;
if ($where eq 'header') {
@@ -424,6 +397,7 @@ sub latex_special_symbols {
$string=~s/\\\%|\%/\\\%/g;
$string=~s/\\{|{/\\{/g;
$string=~s/\\}|}/\\}/g;
+ $string=~s/\\ensuremath\\{\\backslash\\}/\\ensuremath{\\backslash}/g;
$string=~s/\\\$|\$/\\\$/g;
$string=~s/\\\_|\_/\\\_/g;
$string=~s/([^\\]|^)(\~|\^)/$1\\$2\\strut /g;
@@ -784,13 +758,18 @@ sub init_safespace {
# $safeeval->deny(":base_orig");
$safeeval->permit("require");
$safeinit .= ';$external::target="'.$target.'";';
- my $rndseed;
- my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
- $rndseed=&Apache::lonnet::rndseed($symb,$courseid,$domain,$name);
- $safeinit .= ';$external::randomseed="'.$rndseed.'";';
- &Apache::lonxml::debug("Setting rndseed to $rndseed");
&Apache::run::run($safeinit,$safeeval);
+ &initialize_rndseed($safeeval);
+}
+sub initialize_rndseed {
+ my ($safeeval)=@_;
+ my $rndseed;
+ my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
+ $rndseed=&Apache::lonnet::rndseed($symb,$courseid,$domain,$name);
+ my $safeinit = '$external::randomseed="'.$rndseed.'";';
+ &Apache::lonxml::debug("Setting rndseed to $rndseed");
+ &Apache::run::run($safeinit,$safeeval);
}
sub default_homework_load {
@@ -1087,7 +1066,7 @@ sub parstring {
sub writeallows {
unless ($#extlinks>=0) { return; }
- my $thisurl='/res/'.&Apache::lonnet::declutter(shift);
+ my $thisurl = &Apache::lonnet::clutter(shift);
if ($env{'httpref.'.$thisurl}) {
$thisurl=$env{'httpref.'.$thisurl};
}
@@ -1233,10 +1212,7 @@ FULLPAGE
$xml_help=&Apache::loncommon::helpLatexCheatsheet();
}
my $cleanbut = '';
- if ($filetype eq 'html') {
- $cleanbut='';
- }
+
my $titledisplay=&display_title();
my %lt=&Apache::lonlocal::texthash('st' => 'Save this',
'vi' => 'View',
@@ -1324,7 +1300,7 @@ sub handler {
# Edit action? Save file.
#
unless ($env{'request.state'} eq 'published') {
- if (($env{'form.savethisfile'}) || ($env{'form.attemptclean'})) {
+ if ($env{'form.savethisfile'}) {
if (&storefile($file,$env{'form.filecont'})) {
&Apache::lonxml::info("".
&mt('Updated').": ".
@@ -1363,10 +1339,6 @@ ENDNOTFOUND
if ($filecontents=~/BEGIN LON-CAPA Internal/) {
&Apache::lonxml::error(&mt('This file appears to be a rendering of a Lon-CAPA resource. If this is correct, this resource will act very oddly and incorrectly.'));
}
-
- if ($env{'form.attemptclean'}) {
- $filecontents=&htmlclean($filecontents,1);
- }
#
# we are in construction space, see if edit mode forced
&Apache::loncommon::get_unprocessed_cgi
@@ -1484,8 +1456,6 @@ sub warning {
if ($env{'form.grade_target'} ne 'tex') {
if ( &show_error_warn_msg() ) {
- my $request=$Apache::lonxml::request;
- if (!$request) { $request=Apache->request; }
push(@Apache::lonxml::warning_messages,
$Apache::lonxml::warnings_error_header.
"WARNING:".join('
',@_)."
\n");