[LON-CAPA-cvs] cvs: loncom /localize lonlocal.pm

bowersj2 lon-capa-cvs@mail.lon-capa.org
Thu, 02 Oct 2003 17:35:57 -0000


bowersj2		Thu Oct  2 13:35:57 2003 EDT

  Modified files:              
    /loncom/localize	lonlocal.pm 
  Log:
  Add a normalization function to lonlocal.
  
  
Index: loncom/localize/lonlocal.pm
diff -u loncom/localize/lonlocal.pm:1.16 loncom/localize/lonlocal.pm:1.17
--- loncom/localize/lonlocal.pm:1.16	Mon Sep 29 09:24:49 2003
+++ loncom/localize/lonlocal.pm	Thu Oct  2 13:35:57 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Localization routines
 #
-# $Id: lonlocal.pm,v 1.16 2003/09/29 13:24:49 www Exp $
+# $Id: lonlocal.pm,v 1.17 2003/10/02 17:35:57 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -280,6 +280,18 @@
 ###    setlocale(LC_ALL,&current_locale);
 }
 
+# ==================== Normalize string (reduce fragility in the lexicon files)
+
+# This normalizes a string to reduce fragility in the lexicon files of
+# huge messages (such as are used by the helper), and allow useful
+# formatting: reduce all consecutive whitespace to a single space,
+# and remove all HTML
+sub normalize_string {
+    my $s = shift;
+    $s =~ s/\s+/ /g;
+    $s =~ s/<[^>]+>//g;
+    return $s;
+}
 1;
 
 __END__