change bbcode parse order + code tag sanitising
This commit is contained in:
parent
768128a584
commit
8b662ba0eb
2 changed files with 19 additions and 19 deletions
|
@ -21,6 +21,23 @@ class Parser
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $parsers = [
|
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
|
// Basic markup
|
||||||
Tags\Bold::class,
|
Tags\Bold::class,
|
||||||
Tags\Italics::class,
|
Tags\Italics::class,
|
||||||
|
@ -30,27 +47,10 @@ class Parser
|
||||||
Tags\Image::class,
|
Tags\Image::class,
|
||||||
Tags\Spoiler::class,
|
Tags\Spoiler::class,
|
||||||
|
|
||||||
// More advanced
|
|
||||||
Tags\Colour::class,
|
|
||||||
Tags\Align::class,
|
|
||||||
Tags\Size::class,
|
|
||||||
Tags\YouTube::class,
|
|
||||||
|
|
||||||
// Links
|
// Links
|
||||||
Tags\NamedLink::class,
|
Tags\NamedLink::class,
|
||||||
Tags\Link::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
|
// Newline must always be last
|
||||||
Tags\Newline::class,
|
Tags\Newline::class,
|
||||||
];
|
];
|
||||||
|
|
|
@ -28,9 +28,9 @@ class Code extends TagBase
|
||||||
'/\[code(?:\=([a-z]+))?\](.*?)\[\/code\]/s',
|
'/\[code(?:\=([a-z]+))?\](.*?)\[\/code\]/s',
|
||||||
function ($matches) {
|
function ($matches) {
|
||||||
$class = strlen($matches[1]) ? "lang-{$matches[1]}" : '';
|
$class = strlen($matches[1]) ? "lang-{$matches[1]}" : '';
|
||||||
// htmlencode bbcode characters here as well
|
$text = str_replace(['[', ']'], ['[', ']'], $matches[2]);
|
||||||
|
|
||||||
return "<pre class='bbcode__code'><code class='bbcode__code-container {$class}'>{$matches[2]}</code></pre>";
|
return "<pre class='bbcode__code'><code class='bbcode__code-container {$class}'>{$text}</code></pre>";
|
||||||
},
|
},
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
|
Reference in a new issue