OK, I'm done with the preg_replace() in the paragraph parser. It's too buggy. Replaced with preg_match_all()/str_replace_once().
authorDan
Tue, 13 Oct 2009 12:44:27 -0400
changeset 1130 c308b471ed82
parent 1129 d56a55a3011b
child 1131 adfbe522c95f
OK, I'm done with the preg_replace() in the paragraph parser. It's too buggy. Replaced with preg_match_all()/str_replace_once().
includes/wikiengine/parse_mediawiki.php
--- a/includes/wikiengine/parse_mediawiki.php	Wed Oct 07 13:01:00 2009 -0400
+++ b/includes/wikiengine/parse_mediawiki.php	Tue Oct 13 12:44:27 2009 -0400
@@ -206,7 +206,17 @@
               )
                 ;sx";
                 
-    $text = preg_replace($regex, '<_paragraph_bypass>$0</_paragraph_bypass>', $text);
+    // using preg_replace here sometimes gives us empty strings probably because we're using $0
+    // in the replace formatter. so we'll just take care of it explicitly here with preg_match_all
+    // and good ole str_replace_once.
+    if ( preg_match_all($regex, $text, $matches) )
+    {
+      foreach ( $matches[0] as $match )
+      {
+        $text = str_replace_once($match, '<_paragraph_bypass>' . $match . '</_paragraph_bypass>', $text);
+      }
+    }
+    
     RenderMan::tag_unstrip('_paragraph_bypass', $text, $_nw, true);
     
     // This is potentially a hack. It allows the parser to stick in <_paragraph_bypass> tags