Index: typogrify.class.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/typogrify/typogrify.class.php,v
retrieving revision 1.2
diff -u -r1.2 typogrify.class.php
--- typogrify.class.php	13 Jan 2009 11:54:17 -0000	1.2
+++ typogrify.class.php	21 Apr 2009 00:18:07 -0000
@@ -158,7 +158,12 @@
    */
   public static function widont($text) {
     // This regex is a beast, tread lightly
-    $widont_finder = "/([^\s])\s+(((<(a|span|i|b|em|strong|acronym|caps|sub|sup|abbr|big|small|code|cite|tt)[^>]*>)*\s*[^\s<>]+)(<\/(a|span|i|b|em|strong|acronym|caps|sub|sup|abbr|big|small|code|cite|tt)>)*[^\s<>]*\s*(<\/(p|h[1-6]|li)>|$))/i";
+    $widont_finder = "/(\s+)                                  # the space to replace
+                      ([^<>\s]+                               # must be flollowed by non-tag non-space characters
+                      \s*                                     # optional white space! 
+                      (<\/(a|em|span|strong|i|b)[^>]*>\s*)*   # optional closing inline tags with optional white space after each
+                      ((<\/(p|h[1-6]|li|dt|dd)>)|$))          # end with a closing p, h1-6, li or the end of the string
+                      /x";
     return preg_replace($widont_finder, '$1&nbsp;$2', $text);
   }
 

