--- highlight.module	2006-12-11 03:43:11.000000000 +0100
+++ highlight.module.new	2007-11-05 12:09:33.000000000 +0100
@@ -257,19 +257,24 @@ function highlight_process($text, $keys)
   // replace "+" with spaces to catch all instances
   $string = str_replace("+", ",", $string);
 
-  if ($_GET['highlight']) {$string .= "," . $_GET['highlight'];}
-  
+  if ($_GET['highlight']) {
+    if ($string)
+      $string .= ',' . $_GET['highlight'];
+    else
+      $string = $_GET['highlight'];
+  }
+
   // strip out any dangerous stuff
   $pattern = "/[^, a-zA-Z 0-9_\.]/";  
   $keys =  preg_replace($pattern, "", $string);  
 
   $keys = explode(",",$keys);
 
+  $replace_text = str_replace("%key%", '$1', $replace_text);
   foreach($keys as $key) {
-    $replacement[] = str_replace("%key%", $key, $replace_text);
+    $text = preg_replace("/($key)/i", $replace_text, $text);
   }
   
-  $text = str_replace($keys, $replacement, $text);
  return $text;
 }
 
