Index: excerpt.install
===================================================================
--- excerpt.install	(revision 59)
+++ excerpt.install	(working copy)
@@ -2,6 +2,47 @@
 /* $Id: excerpt.install,v 1.5 2009/03/31 01:32:53 weitzman Exp $ */
 
 /**
+ * Implementation of hook_schema().
+ */
+function excerpt_schema() {
+  $schema['excerpt'] = array(
+    'description' => 'A table for node\'s extra excerpt information.',
+    'fields' => array(
+      'nid' => array(
+        'description' => 'The {node} this version belongs to.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0),
+      'vid' => array(
+        'description' => 'The primary identifier for this version.',
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'format' => array(
+        'description' => "The input format used by this version's excerpt.",
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0)
+      ),
+    'indexes' => array(
+      'nid' => array('nid'),
+      ),
+    'primary key' => array('vid'),
+  );
+
+  db_query("UPDATE {system} SET weight = -10 WHERE name = 'excerpt'");
+  return $schema;
+ }
+
+/**
+ * Implementation of hook_install().
+ */
+function excerpt_install() {
+  drupal_install_schema('excerpt');
+}
+
+/**
  * Implementation of hook_uninstall().
  */
 function excerpt_uninstall() {
@@ -10,6 +51,29 @@ function excerpt_uninstall() {
 }
 
 /**
+ * Creates the excerpt schema.
+ */
+function excerpt_update_6001() {
+  $ret = array();
+  
+  drupal_install_schema('excerpt');
+
+  return $ret;
+}
+
+/**
+ * Sets the module's weight to -10 to make sure it is run first.
+ */
+function excerpt_update_6002() {
+  $ret = array();
+
+  db_query("UPDATE {system} SET weight = -10 WHERE name = 'excerpt'");
+  
+  return $ret;
+}
+
+
+/**
  * @defgroup updates-4.7-to-5.0 Excerpt updates from 4.7 to 5.0
  * @{
  */
Index: excerpt.module
===================================================================
--- excerpt.module	(revision 59)
+++ excerpt.module	(working copy)
@@ -28,10 +28,45 @@ function excerpt_nodeapi(&$node, $op, $a3 = NULL,
         // shown. With excerpts however, teasers can be even longer than the
         // body field, which is why we need to overwrite that property with our
         // own condition.
-        return array('excerpt' => (bool)strcmp($node->teaser, $node->body));
+        $excerpt = db_fetch_object(db_query("SELECT * FROM {excerpt} WHERE nid = %d AND vid = %d", $node->nid, $node->vid));
+        return array(
+          'excerpt' => (bool)strcmp($node->teaser, $node->body),
+          'teaser_format' => $excerpt->format,
+        );
 
+      case 'delete revision':
+        db_query("DELETE FROM {excerpt} WHERE nid = %d and vid = %d", $node->nid, $node->vid);
+        break;
+
+      case 'delete':
+        db_query("DELETE FROM {excerpt} WHERE nid = %d", $node->nid);
+        break;
+
+      case 'update':
+        // Existing nodes may not have an excerpt information stored,
+        // Check to see if we need to update one or create a new one.
+        $excerpt = db_fetch_object(db_query("SELECT * FROM {excerpt} WHERE nid = %d AND vid = %d", $node->nid, $node->vid));
+        if (empty($node->revision) && $excerpt) {
+          $primary_keys = array('vid');
+        }
+      case 'insert':
+        $excerpt = array();
+        $excerpt['vid'] = $node->vid;
+        $excerpt['nid'] = $node->nid;
+        $excerpt['format'] = $node->teaser_format;
+        drupal_write_record('excerpt', $excerpt, $primary_keys);
+        break;
+
       case 'view':
         $node->readmore = $node->excerpt;
+
+        // Because now we control the format of the teaser, we should check
+        // its markup against it
+        // See @node_prepare, @node_build_content
+        // As we are 'setting' the teaser, and not adding content,
+        // we want this module's hook to be called first of all,
+        // that's why the module's weight is set to -10 in the install file
+        $node->teaser = check_markup($node->teaser, $node->teaser_format, FALSE);
         break;
     }
   }
@@ -58,15 +93,18 @@ function excerpt_form_alter(&$form, $form_state, $
   }
   }
   else if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && variable_get('excerpt_'. $form['type']['#value'], 1) == 1) {
-    $form['teaser'] = array(
+    $form['teaser_field'] = array(
+      '#weight' => module_exists('content') ? content_extra_field_weight($form['type']['#value'], 'teaser') : variable_get('excerpt_wt_'. $form['type']['#value'], 0),
+      );
+    $form['teaser_field']['teaser'] = array(
       '#type' => 'textarea',
       '#title' => t('Teaser'),
       '#default_value' => $form['#node']->teaser,
       '#cols' => 60,
-      '#rows' => 6,
-      '#weight' => module_exists('content') ? content_extra_field_weight($form['type']['#value'], 'teaser') : variable_get('excerpt_wt_'. $form['type']['#value'], 0),
+      '#rows' => $form['body_field']['body']['#rows'],
       '#description' => t('Enter an excerpt for this item. It will be shown on listing pages along with a <em>read more</em> link which leads to the full view. Leave empty to auto-generate one from the body.'),
     );
+    $form['teaser_field']['format'] = filter_form($form['#node']->teaser_format, 1, array('teaser_format'));
 
     $form['body_field']['body']['#default_value'] = $form['#node']->body;
 
@@ -103,5 +141,4 @@ function excerpt_content_extra_fields($type_name)
   }
 
   return $extra;
-}
-
+}
\ No newline at end of file
