--- loncom/xml/lonxml.pm	2004/08/29 08:17:22	1.332.2.1
+++ loncom/xml/lonxml.pm	2004/08/10 18:25:53	1.335
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.332.2.1 2004/08/29 08:17:22 albertel Exp $
+# $Id: lonxml.pm,v 1.335 2004/08/10 18:25:53 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -165,13 +165,21 @@ sub xmlbegin {
 }
 
 sub xmlend {
+    my ($target,$parser)=@_;
     my $mode='xml';
     my $status='OPEN';
     if ($Apache::lonhomework::parsing_a_problem) {
 	$mode='problem';
 	$status=$Apache::inputtags::status[-1]; 
     }
-    return &Apache::lonfeedback::list_discussion($mode,$status).'</html>';
+    my $discussion=&Apache::lonfeedback::list_discussion($mode,$status);    
+    if ($target eq 'tex') {
+	$discussion.='<tex>\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\end{document}</tex>';
+	&Apache::lonxml::newparser($parser,\$discussion,'');
+	return '';
+    } else {
+	return $discussion.'</html>';
+    }
 }
 
 sub tokeninputfield {
@@ -1127,7 +1135,8 @@ sub inserteditinfo {
       my $initialize='';
       if ($filetype eq 'html') {
 	  my $addbuttons=&Apache::lonhtmlcommon::htmlareaaddbuttons();
-	  $initialize=&Apache::lonhtmlcommon::htmlareaheaders().(<<FULLPAGE);
+	  $initialize=&Apache::lonhtmlcommon::htmlareaheaders().
+	      &Apache::lonhtmlcommon::spellheader().(<<FULLPAGE);
 <script type="text/javascript">
 $addbuttons
 
@@ -1157,12 +1166,12 @@ $cleanbut
 <input type="submit" name="savethisfile" accesskey="s"  value="$lt{'st'}" />
 <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />
 BUTTONS
-      $buttons.=&Apache::lonhtmlcommon::htmlareaselectactive('filecont');
+      $buttons.=&Apache::lonhtmlcommon::spelllink('xmledit','filecont');
       my $editfooter=(<<ENDFOOTER);
 $initialize
 <hr />
 <a name="editsection" />
-<form method="post">
+<form method="post" name="xmledit">
 $xml_help
 <input type="hidden" name="editmode" value="$lt{'ed'}" />
 $buttons<br />