diff --git a/app/BBCode/Parser.php b/app/BBCode/Parser.php index a88996d..f513a28 100644 --- a/app/BBCode/Parser.php +++ b/app/BBCode/Parser.php @@ -21,6 +21,23 @@ class Parser * @var array */ public static $parsers = [ + // Advanced parsing + Tags\Code::class, + Tags\Box::class, + Tags\ListTag::class, + Tags\UserTag::class, + Tags\Markdown::class, + + // Quotes + Tags\NamedQuote::class, + Tags\Quote::class, + + // More advanced + Tags\Colour::class, + Tags\Align::class, + Tags\Size::class, + Tags\YouTube::class, + // Basic markup Tags\Bold::class, Tags\Italics::class, @@ -30,27 +47,10 @@ class Parser Tags\Image::class, Tags\Spoiler::class, - // More advanced - Tags\Colour::class, - Tags\Align::class, - Tags\Size::class, - Tags\YouTube::class, - // Links Tags\NamedLink::class, Tags\Link::class, - // Quotes - Tags\NamedQuote::class, - Tags\Quote::class, - - // Advanced parsing - Tags\Box::class, - Tags\Code::class, - Tags\ListTag::class, - Tags\UserTag::class, - Tags\Markdown::class, - // Newline must always be last Tags\Newline::class, ]; diff --git a/app/BBCode/Tags/Code.php b/app/BBCode/Tags/Code.php index b0b6d4b..7d7bb84 100644 --- a/app/BBCode/Tags/Code.php +++ b/app/BBCode/Tags/Code.php @@ -28,9 +28,9 @@ class Code extends TagBase '/\[code(?:\=([a-z]+))?\](.*?)\[\/code\]/s', function ($matches) { $class = strlen($matches[1]) ? "lang-{$matches[1]}" : ''; - // htmlencode bbcode characters here as well + $text = str_replace(['[', ']'], ['[', ']'], $matches[2]); - return "
{$matches[2]}
"; + return "
{$text}
"; }, $text );