MyBB Community Forums

Full Version: Parsing of BBCode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello folks, daily dose of spasms here.

I am having an issue where bbcode is parsing fine, just not breaking lines. (newline breaks).

As seen on this image where each Line# is a line in the editor:
[Image: DN81sPu.png]

Problem is, with identical code I've never had this issue before, and I'm beginning to suspect it doesn't really have anything to do with the post parser.

This is how the bbcode is inserted and how it is parsed:

First how I insert the message into DB:
$db->escape_string($mybb->input['description'])

Then how I parse it before I use it in a template:
$description = $parser->parse_message($item['description'], $parser_options);

How it looks without parsing:
Line1 [b]Line2[/b] [i]Line3[/i] [u]Line4[/u] [s]Line5[/s] [color=#9a00b2]Line6[/color]

The actual description inside the db is breaking lines:
[Image: ifobx69.png]
And I've tried other things too just to play around, this is just the most recent.

At last the parser options I'm using:
$parser_options = array(
    'allow_html' => 'no',
    'allow_mycode' => 'yes',
    'allow_smilies' => 'yes',
    'allow_imgcode' => 'yes',
    'filter_badwords' => 'yes',
    'nl2br' => 'yes'
    );

If anyone can spot the issue I'd appreciate it a lot. As always, insanely grateful for any help.
$parser_options does not accept yes/no string values. You must use numerical binary values, eg. 0 or 1

https://github.com/mybb/mybb/blob/1326ee...r.php#L145