Rasmus Vind
Well-known member
I made a custom BB Code called "noparse" that should do the same as the existing tag called "plain". This was the simplest BB code I needed to port from my old vBulletin site. I have some much more complex for code highlighting. They all share the same problem.
I set the following setting in the BB Code:
Stop parsing BB code: ON
When I post something like [noparse][b]Test[b]Test[b]Test[/noparse] and press "Edit" and see the WYSIWYG editor, the [b] tags are interpreted and the text becomes bold ignoring the setting.
I went into XenForo_BbCode_Formatter_Wysiwyg and added 'noparse' to the $_undisplayableTags variable. But this had no effect. How can I make my custom BB code behave the same way as [code] and [plain]?
The reason for this being reported as a bug is that I think "Stop parsing BB code" should stop it from being parsed in the WYSIWYG editor too.
EDIT:
After intense debugging and inspecting I have found how to solve the problem. The problem is that standard BB codes are the only ones that the parser will not parse into even when setting "Stop parsing BB code" to true. The standard parser does simply not seem to be getting the custom BB codes.
I made my fix by extending the class XenForo_BbCode_Formatter_Wysiwyg using the hook load_class_bb_code.
This properly informed the parser to ignore the tag.
EDIT:
Okay, I believe this to be a bug. The Wysiwyg BB Code formatter must get all the custom BB codes so the codes with the plainChildren property set to true are correctly parsed by the parser.
I set the following setting in the BB Code:
Stop parsing BB code: ON
When I post something like [noparse][b]Test[b]Test[b]Test[/noparse] and press "Edit" and see the WYSIWYG editor, the [b] tags are interpreted and the text becomes bold ignoring the setting.
I went into XenForo_BbCode_Formatter_Wysiwyg and added 'noparse' to the $_undisplayableTags variable. But this had no effect. How can I make my custom BB code behave the same way as [code] and [plain]?
The reason for this being reported as a bug is that I think "Stop parsing BB code" should stop it from being parsed in the WYSIWYG editor too.
EDIT:
After intense debugging and inspecting I have found how to solve the problem. The problem is that standard BB codes are the only ones that the parser will not parse into even when setting "Stop parsing BB code" to true. The standard parser does simply not seem to be getting the custom BB codes.
I made my fix by extending the class XenForo_BbCode_Formatter_Wysiwyg using the hook load_class_bb_code.
PHP:
<?php
class RaBbCodeMisc_Wysiwyg extends XFCP_RaBbCodeMisc_Wysiwyg
{
public function getTags()
{
$tags = parent::getTags();
$tags = array_merge($tags, array(
'noparse' => array(
'stopSmilies' => true,
'stopLineBreakConversion' => true,
'trimLeadingLinesAfter' => 2,
'plainChildren' => true,
),
));
return $tags;
}
}
This properly informed the parser to ignore the tag.
EDIT:
Okay, I believe this to be a bug. The Wysiwyg BB Code formatter must get all the custom BB codes so the codes with the plainChildren property set to true are correctly parsed by the parser.
Last edited: