--- loncom/xml/lonxml.pm	2002/09/11 13:36:50	1.195
+++ loncom/xml/lonxml.pm	2002/10/03 15:04:29	1.198
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.195 2002/09/11 13:36:50 www Exp $
+# $Id: lonxml.pm,v 1.198 2002/10/03 15:04:29 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -99,6 +99,7 @@ use Apache::edit();
 use Apache::lonnet();
 use Apache::File();
 use Apache::loncommon();
+use Apache::lonfeedback();
 
 #==================================================   Main subroutine: xmlparse  
 #debugging control, to turn on debugging modify the correct handler
@@ -186,17 +187,24 @@ sub xmlend {
                   if ($hidden) {
 		      $message='<font color="#888888">'.$message.'</font>';
                   }
+                  my $screenname=&Apache::loncommon::screenname(
+                               $contrib{$idx.':sendername'},
+			       $contrib{$idx.':senderdomain'});
+                  my $plainname=&Apache::loncommon::nickname(
+                               $contrib{$idx.':sendername'},
+			       $contrib{$idx.':senderdomain'});
+
                   my $sender='Anonymous';
                   if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
                       $sender=&Apache::loncommon::aboutmewrapper(
-                               $contrib{$idx.':plainname'},
+                               $plainname,
                                $contrib{$idx.':sendername'},
                                $contrib{$idx.':senderdomain'}).' ('.
                               $contrib{$idx.':sendername'}.' at '.
 		      $contrib{$idx.':senderdomain'}.')';
                       if ($contrib{$idx.':anonymous'}) {
 			  $sender.=' [anonymous] '.
-                                     $contrib{$idx.':screenname'};
+                                     $screenname;
                       }
                       if ($seeid) {
 			  if ($hidden) {
@@ -208,8 +216,8 @@ sub xmlend {
 			  }
                       }                   
                   } else {
-                      if ($contrib{$idx.':screenname'}) {
-			  $sender='<i>'.$contrib{$idx.':screenname'}.'</i>';
+                      if ($screenname) {
+			  $sender='<i>'.$screenname.'</i>';
                       }
                   }
 		  $discussion.='<p><b>'.$sender.'</b> ('.
@@ -225,7 +233,7 @@ sub xmlend {
           }
           if ($discussiononly) {
 	      $discussion.=(<<ENDDISCUSS);
-<form action="/adm/feedback" method="post">
+<form action="/adm/feedback" method="post" name="mailform">
 <input type="submit" name="discuss" value="Post Discussion" />
 <input type="submit" name="anondiscuss" value="Post Anonymous Discussion" />
 <input type="hidden" name="symb" value="$symb" />
@@ -236,6 +244,7 @@ course faculty</font><br />
 <textarea name=comment cols=60 rows=10 wrap=hard></textarea>
 </form>
 ENDDISCUSS
+             $discussion.=&Apache::lonfeedback::generate_preview_button();
           }
        }
     }
@@ -356,6 +365,7 @@ sub registerurl {
     my $forcereg=shift;
     my $target = shift;
     my $result = '';
+    
     if ($target eq 'edit') {
         $result .="<script>\n".
             "if (typeof menu != 'undefined') {menu.currentURL=null;}\n".
@@ -568,8 +578,12 @@ sub latex_special_symbols {
     $current_token=~s/\\/\\char92 /g;
     $current_token=~s/\^/\\char94 /g;
     $current_token=~s/\~/\\char126 /g;
-    $current_token=~s/(&[^a-z#])/\\$1/g;
-    $current_token=~s/([^&]\#)/\\$1/g;
+    $current_token=~s/(&[^a-z\#])/\\$1/g;
+    if ($current_token=~/ \#\w/) {
+	$current_token=~s/ \#(\w)/ \\#$1/;
+    } else {
+	$current_token=~s/([^&]\#)/\\$1/g;
+    }
     $current_token=~s/(\$|_|{|})/\\$1/g;
     $current_token=~s/\\char92 /\\texttt{\\char92}/g;
     $current_token=~s/>/\$>\$/g; #more