Index: tableofcontents.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tableofcontents/tableofcontents.module,v
retrieving revision 1.2.4.2.2.13
diff -u -r1.2.4.2.2.13 tableofcontents.module
--- tableofcontents.module	22 Oct 2008 21:19:56 -0000	1.2.4.2.2.13
+++ tableofcontents.module	30 Oct 2008 15:09:15 -0000
@@ -249,6 +249,13 @@
     '#default_value' => variable_get('tableofcontents_allow_override_' . $format, TRUE),
   );
   
+  $form['tableofcontents']['tableofcontents_remove_teaser_' . $format] = array(
+    '#title' => t('Remove Table of Contents tags from teasers'),
+    '#type' => 'checkbox',
+    '#default_value' => variable_get("tableofcontents_remove_teaser_$format", TRUE),
+    '#description' => t('If this setting is changed, each node may need to be re-edited to reflect the new setting. If you have many nodes, the <a href="@retease">Retease module</a> can help to do this automatically.', array('@retease' => url('http://drupal.org/project/retease'))),
+  );
+  
   $form['tableofcontents']['tableofcontents_title_' . $format] = array(
     '#title' => t('Table of Contents Title'),
     '#type' => 'textfield',
@@ -324,6 +331,18 @@
         cache_clear_all($cid, 'cache_filter');
       }
       break;
+      
+    case 'submit':
+      if (variable_get("tableofcontents_remove_teaser_$node->format", TRUE)) {
+        $filters = filter_list_format($node->format);
+        if (isset($filters['tableofcontents/0'])) {
+          if ($node->teaser && ($node->teaser != $new_teaser = preg_replace('!<\!-- ?tableofcontents(.*)-->!', '', $node->teaser))) {
+            // Remove toc from teasers.
+            $node->teaser = $new_teaser;
+          }
+        }
+      }
+      break;
   }
 }
 
