? .heading_norm_filter.module.swp
Index: heading_norm_filter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/heading_norm_filter/heading_norm_filter.module,v
retrieving revision 1.1
diff -u -p -r1.1 heading_norm_filter.module
--- heading_norm_filter.module	5 Sep 2009 11:39:14 -0000	1.1
+++ heading_norm_filter.module	21 Sep 2009 23:19:39 -0000
@@ -86,14 +86,14 @@ function theme_heading_norm_filter_headi
   // protect heading_norm_filter by h_heading_norm_filte
   if ($level>6) {
     return array(
-      0 => '<p class="heading-norm-orig-h' . $origlevel . ' heading-norm-h' . $level . '">',
-      1 => '</p>',
+      0 => '<p class="heading-norm-orig-h' . $origlevel . ' heading-norm-h' . $level . '"',
+      1 => '</p',
     );
   }
   else {
     return array(
-      0 => '<h' . HEADING_NORM_PROTECTOR . $level . ' class="heading-norm-orig-h' . $origlevel . '">',
-      1 => '</h' . HEADING_NORM_PROTECTOR . $level . '>',
+      0 => '<h' . HEADING_NORM_PROTECTOR . $level . ' class="heading-norm-orig-h' . $origlevel . '"',
+      1 => '</h' . HEADING_NORM_PROTECTOR . $level . '',
   );
   }
 }
@@ -160,10 +160,7 @@ function heading_norm_filter_settings() 
 /**
  * Process the filter on text
  *
- * @param
- *   text
- * @param
- *   type
+ * @param text
  *
  * @return
  *   string replaced text
@@ -180,6 +177,20 @@ function heading_norm_filter_process($te
     $starttag = variable_get('heading_norm_filter_starth', 1);
   }
   $starttag++;
+  return heading_norm_filter_process_from($text, $starttag);
+}
+
+/**
+ * Process the filter on text with starttag
+ *
+ * @param text
+ *
+ * @param starttag
+ *
+ * @return
+ *   string replaced text
+ */
+function heading_norm_filter_process_from($text, $starttag) {
   $h = heading_norm_filter_tag_find($text);
   $text = heading_norm_filter_tag_replace($text, $starttag, $h);
   return $text;
@@ -191,7 +202,7 @@ function heading_norm_filter_process($te
 function heading_norm_filter_tag_find($text) {
   for ($i=1; $i<=6; $i++) {
     // TODO match <h with classes & more
-    if (strpos($text, '<h' . $i . '>') !== FALSE) {
+    if (stripos($text, '<h' . $i) !== FALSE) {
       $h[$i] = 1;
     }
     else {
@@ -208,14 +219,15 @@ function heading_norm_filter_tag_find($t
  */
 
 function heading_norm_filter_tag_replace($text, $start, $existent) {
+  $orig = $text;
   // check global state
   $j = $start;
   for ($i=1; $i<=6; $i++) {
     // TODO check markup structure h up/same/+1
     if ($existent[$i]==1) {
       $replace = theme('heading_norm_filter_heading', $j, $i);
-      $text = str_replace('<h' . $i . '>', $replace[0], $text);
-      $text = str_replace('</h' . $i . '>', $replace[1], $text);
+      $text = preg_replace('|<h' . $i . '|i', $replace[0], $text);
+      $text = preg_replace('|</h' . $i . '|i', $replace[1], $text);
     }
     $j++;
   }
