diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 5474be98d..e417b38a4 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1180,17 +1180,18 @@ class BBCode extends BaseObject return $return; }; - // Extracting multi-line code blocks before the whitespace processing + // Extracting code blocks before the whitespace processing and the autolinker $codeblocks = []; $text = preg_replace_callback("#\[code(?:=([^\]]*))?\](.*?)\[\/code\]#ism", function ($matches) use (&$codeblocks) { - $return = $matches[0]; + $return = '#codeblock-' . count($codeblocks) . '#'; if (strpos($matches[2], "\n") !== false) { - $return = '#codeblock-' . count($codeblocks) . '#'; - - $codeblocks[] = '
' . trim($matches[2], "\n\r") . '
';
+ $codeblocks[] = '' . trim($matches[2], "\n\r") . '
';
+ } else {
+ $codeblocks[] = '' . $matches[2] . '
';
}
+
return $return;
},
$text
@@ -1502,12 +1503,6 @@ class BBCode extends BaseObject
// Check for font change text
$text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm", "$2", $text);
- // Declare the format for [code] layout
-
- $CodeLayout = '$1
';
- // Check for [code] text
- $text = preg_replace("/\[code\](.*?)\[\/code\]/ism", "$CodeLayout", $text);
-
// Declare the format for [spoiler] layout
$SpoilerLayout = '$1';