--- loncom/xml/lonxml.pm	2003/10/24 21:31:05	1.287
+++ loncom/xml/lonxml.pm	2003/11/20 21:43:24	1.293
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.287 2003/10/24 21:31:05 albertel Exp $
+# $Id: lonxml.pm,v 1.293 2003/11/20 21:43:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -337,6 +337,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 = ();
@@ -395,7 +402,7 @@ sub latex_special_symbols {
 	$string =~ s/_/ /g;
     } else {
 	$string=~s/\\ /\\char92 /g;
-	$string=~s/\^/\\char94 /g;
+	$string=~s/\^/\\\^ /g;
 	$string=~s/\~/\\char126 /g;
 	$string=~s/(&[^A-Za-z\#])/\\$1/g;
 	$string=~s/([^&])\#/$1\\#/g;
@@ -985,6 +992,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\";";
     }
   }
@@ -1060,6 +1068,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();