Fix format catcher (ie // ** __ catcher)
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Thu, 22 Feb 2007 20:49:01 +0000 (20:49 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:32 +0000 (00:35 +0100)
git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@214 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/message.func.inc.php

index 1628f37..de29b94 100644 (file)
@@ -84,15 +84,15 @@ function banana_wordwrap($text, $quote_level)
 
 function banana_catchFormats($text)
 {
-    $formatting = Array('/' => 'em', // match / first in order not to match closing markups </...> <> </>
-                        '_' => 'u',
-                        '*' => 'strong');
+    $formatting = Array('em' => array('\B\/\b', '\b\/\B'),
+                        'u' =>  array('\b_', '_\b'),
+                        'strong' => array('\B\*\b', '\b\*\B'));
     $url = Banana::$msgshow_url;
     preg_match_all("/$url/ui", $text, $urls);
     $text = str_replace($urls[0], "&&&urls&&&", $text);
-    foreach ($formatting as $limit=>$mark) {
-        $limit = preg_quote($limit, '/');
-        $text = preg_replace('/' . $limit . '(\S+?)' . $limit . '/us',
+    foreach ($formatting as $mark=>$limit) {
+        list($ll, $lr) = $limit;
+        $text = preg_replace('/' . $ll . '(\w+?)' . $lr . '/us',
                              "<$mark>\\1</$mark>", $text);
     }
     return preg_replace('/&&&urls&&&/e', 'array_shift($urls[0])', $text);