--- tableofcontents.pages.in-revBASE.svn001.tmp.inc	Wed Apr 28 11:35:23 2010
+++ tableofcontents.pages.inc	Wed Apr 28 10:57:26 2010
@@ -107,7 +107,7 @@
       $path = drupal_get_path('module', 'tableofcontents');
       $toc_translations = parse_ini_file($path . '/i18n-ascii.txt');
     }
-    $title = strtr($h->title, $toc_translations);
+    $title = strtr(strip_tags($h->title), $toc_translations);
 
     $id = preg_replace(
       array(
@@ -116,8 +116,8 @@
         '/&mdash;/',
         '/&amp;/',
         '/&[a-z]+;/',
-        '/[^-A-Za-z0-9._:]/',
-        '/^[0-9]+/',
+        '/[^-A-Za-z_:]/',
+        '/^[0-9|_]+/',
       ),
       array(
         '_',     // &nbsp; and spaces
@@ -125,8 +125,8 @@
         '--',    // &mdash;
         'and',   // &amp;
         '',      // any other entity
-        '',      // any character that is invalid as an ID name
-        '',      // any digits at the start of the name
+        '',      // any character that is invalid as an ID name (digits and "." periods aren't working for me)
+        '',      // any digits or underscores at the start of the name
       ),
       $title
     );
@@ -868,7 +868,7 @@
       }
       $list_class = 'toc-level-' . ($level - $toc->minlevel + 1);
 
-      $title = preg_replace('%</?a[^>]+>%', '', $h->title);
+      $title = strip_tags($h->title);
 
       // insert the li element
       $output .= "\t<li class=\"$list_class\"><a href=\"#" . $h->identifier . "\">" . $number . $title . "</a>";
