Index: tableofcontents.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tableofcontents/tableofcontents.module,v
retrieving revision 1.2.4.2.2.14
diff -u -r1.2.4.2.2.14 tableofcontents.module
--- tableofcontents.module	14 Dec 2008 03:07:12 -0000	1.2.4.2.2.14
+++ tableofcontents.module	2 Jan 2009 20:09:57 -0000
@@ -95,6 +95,9 @@
       // get all toc markers and options
       preg_match_all('!<\!-- ?tableofcontents(.*)-->!', $text, $options_str, PREG_PATTERN_ORDER);
 
+      // Replace angle brackets as per http://drupal.org/node/209715.
+      $text = preg_replace('!<\!-- ?tableofcontents(.*)-->!', '[tableofcontents-toc]$1[/tableofcontents-toc]', $text);
+
       // to optimize performance enclose preparation in conditional that tests for presence of ToC marker
       if (!empty($options_str[0]) && $options_str[0][0] != "") {
 
@@ -186,7 +189,7 @@
         $toc_options["minlevel"] . '-' .
         $toc_options["maxlevel"] . '])>/is';
         
-        preg_match('!<\!-- ?tableofcontents(.*)-->!', $text, $matches, PREG_OFFSET_CAPTURE);
+        preg_match('!\[tableofcontents-toc](.*)\[/tableofcontents-toc]!', $text, $matches, PREG_OFFSET_CAPTURE);
         $heading_search_text = substr($text, $matches[0][1]);
         
         $matches = array();
@@ -222,7 +225,7 @@
         $toc_html = theme('tableofcontents_toc', $toc, $toc_options, $files);
 
         // replace all tableofcontents markers with generated ToC html
-        return preg_replace('!<\!-- ?tableofcontents(.*)-->!', $toc_html, $text);
+        return preg_replace('!\[tableofcontents-toc].*\[/tableofcontents-toc]!', $toc_html, $text);
       }
       else {
         return $text;
@@ -336,6 +339,8 @@
       if (variable_get("tableofcontents_remove_teaser_$node->format", TRUE)) {
         $filters = filter_list_format($node->format);
         if (isset($filters['tableofcontents/0'])) {
+          // We can leave the angle brackets here as this occurs before content
+          // filtering.
           if ($node->teaser && ($node->teaser != $new_teaser = preg_replace('!<\!-- ?tableofcontents(.*)-->!', '', $node->teaser))) {
             // Remove toc from teasers.
             $node->teaser = $new_teaser;
