[LON-CAPA-cvs] cvs: loncom /interface entities.pm lonprintout.pm /xml londefdef.pm

foxr lon-capa-cvs-allow@mail.lon-capa.org
Tue, 29 Apr 2008 10:16:38 -0000


foxr		Tue Apr 29 06:16:38 2008 EDT

  Modified files:              
    /loncom/interface	entities.pm lonprintout.pm 
    /loncom/xml	londefdef.pm 
  Log:
  1. Fix UTF-8 re-coding in entities.pm
  2. add \usepackage{ucs} to latex header in  
     lonprintout.pm, londefdef.pm.
  
  
  
Index: loncom/interface/entities.pm
diff -u loncom/interface/entities.pm:1.9 loncom/interface/entities.pm:1.10
--- loncom/interface/entities.pm:1.9	Mon Apr 28 06:33:35 2008
+++ loncom/interface/entities.pm	Tue Apr 29 06:15:58 2008
@@ -711,6 +711,10 @@
     8733     => '\ensuremath{\propto}',
     'infin'  => '\ensuremath{\infty}',
     8734     => '\ensuremath{\infty}',
+#
+#   The items below require the isoent latex package which I can't find at least for FC5.
+#   Temporarily commented out.
+#
 #    'ang90'  => '\ensuremath{\sqangle}',
 #    8735     => '\ensuremath{\sqangle}',
     'ang'    => '\ensuremath{\angle}',
@@ -921,6 +925,16 @@
     
 );
 
+#  There are some named entities that don't have a good
+#  latex equivalent, these are converted to utf-8 via this table
+#  of entity name -> unicode number.
+
+my  %utf_table = (
+    'THORN'  => 222,
+    'thorn'  => 254,
+    'eth'    => 240
+);
+
 # 
 #  Convert a numerical entity (that does not exist in our hash)
 #  to its UTF-8 equivalent representation.
@@ -935,8 +949,8 @@
 #
 sub entity_to_utf8 {
     my ($unicode) = @_;
-
-    return pack("U", $unicode);
+    my $result =  pack("U", $unicode);
+    return $result;
 }
 
 
@@ -969,9 +983,16 @@
 	return $latex;
     }
     # If the text is purely numeric we can do the UTF-8 conversion:
-
-    if ($entity =~ /^\d$/) {
+    # Otherwise there are a few textual entities that don't have good latex
+    # which can be converted to unicode:
+    #
+    if ($entity =~ /^\d+$/) {
 	return &entity_to_utf8($entity);
+    } else {
+	my $result = $utf_table{"$entity"};
+	if (defined $result) {
+	    return &entity_to_utf8($result);
+	}
     }
     #  Can't do the conversion`< ...
 
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.531 loncom/interface/lonprintout.pm:1.532
--- loncom/interface/lonprintout.pm:1.531	Mon Apr 28 06:52:03 2008
+++ loncom/interface/lonprintout.pm	Tue Apr 29 06:15:59 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.531 2008/04/28 10:52:03 foxr Exp $
+# $Id: lonprintout.pm,v 1.532 2008/04/29 10:15:59 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1150,6 +1150,7 @@
 	     '\usepackage[dvips]{graphicx}\usepackage{epsfig}'."\n".
 	     '\usepackage{wrapfig}'.
 	     '\usepackage{picins}\usepackage{calc}'."\n".
+	     '\usepacakge{ucs}'."\n".
 	     '\usepackage[utf8]{inputenc}'."\n".
 	     '\usepackage[T1]{fontenc}'."\n".
 	     '\usepackage{latexsym}'."\n".
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.385 loncom/xml/londefdef.pm:1.386
--- loncom/xml/londefdef.pm:1.385	Mon Apr 28 06:52:33 2008
+++ loncom/xml/londefdef.pm	Tue Apr 29 06:16:37 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.385 2008/04/28 10:52:33 foxr Exp $
+# $Id: londefdef.pm,v 1.386 2008/04/29 10:16:37 foxr Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -200,8 +200,9 @@
                           '\usepackage[dvips]{graphicx}'.
 			  '\usepackage{wrapfig}'.
 			  '\usepackage{picins}'.
-			  '\usepackage[utf8]{inputenc}'."\n".
 			  '\usepackage[T1]{fontenc}'."\n".
+			  '\usepacakge{ucs}'."\n".
+			  '\usepackage[utf8]{inputenc}'."\n".
 			  '\usepackage{latexsym}'."\n".
                           '\usepackage{epsfig}'.
                           '\usepackage{calc}'.