From d1efb59fcdd3d5e78f3071c7a7a959c285782931 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 30 May 2016 16:12:48 +0200 Subject: render code bbcode inline if there are no linebreaks in the text. --- include/bbcode.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index f47dc6f2e..42741b392 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -477,9 +477,12 @@ function bb_observer($Text) { return $Text; } - - - +function bb_code($match) { + if(strpos($match[0], "
")) + return '' . trim($match[1]) . ''; + else + return '' . trim($match[1]) . ''; +} @@ -785,12 +788,9 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "$2", $Text); } - // Declare the format for [code] layout - $CodeLayout = '$1'; - // Check for [code] text if (strpos($Text,'[code]') !== false) { - $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism", "$CodeLayout", $Text); + $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism", 'bb_code', $Text); } // Check for [spoiler] text -- cgit v1.2.3