--- relatedlinks.module.bak	2007-05-08 02:06:48.000000000 +0200
+++ relatedlinks.module	2007-09-23 03:08:52.000000000 +0200
@@ -222,7 +222,12 @@ function relatedlinks_nodeapi(&$node, $o
                 // was adapted from a post on php.net by "martin at vertikal dot dk".
                 // Any updates to this regex also needs to be applied to the
                 // .install file update.
-                preg_match_all("!<\s*a\s*href\s*=\s*(?:\"([^\">]+)\"[^>]*|([^\" >]+?)[^>]*)>(.*)\s*<\s*/\s*a\s*>!Uis", $node->body, $matches);
+
+                // pre-filter node body using check_markup to ensure proper matching of
+                // inline links (not enclosed in anchor tags) and links in non-HTML markup.
+                $prefiltered_node_body = check_markup($node->body, $format = FILTER_FORMAT_DEFAULT, $check = TRUE);
+
+                preg_match_all("!<\s*a\s*href\s*=\s*(?:\"([^\">]+)\"[^>]*|([^\" >]+?)[^>]*)>(.*)\s*<\s*/\s*a\s*>!Uis", $prefiltered_node_body, $matches);
                 $links = _relatedlinks_check_links($matches[1], $matches[3]);
                 _relatedlinks_add_links($node->nid, $links, RELATEDLINKS_PARSED);
               }
