From: x2003bruneau Date: Thu, 22 Feb 2007 20:49:01 +0000 (+0000) Subject: Fix format catcher (ie // ** __ catcher) X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=30402dbcded35ec2885c2860285f7cd9da9413f7;p=banana.git Fix format catcher (ie // ** __ catcher) git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@214 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/banana/message.func.inc.php b/banana/message.func.inc.php index 1628f37..de29b94 100644 --- a/banana/message.func.inc.php +++ b/banana/message.func.inc.php @@ -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", $text); } return preg_replace('/&&&urls&&&/e', 'array_shift($urls[0])', $text);