2020-11-05, 11:48 AM
Hello,
I'm running a roleplay forum and the nl2br feature in parsing creates problems when the users want to use HTML templates for their threads.
The coders are from the Jcink platform, where a MyCode "dohtml" exists; when this "dohtml" code is used, new lines are NOT converted to <br>. Jcink isn't open source, so I don't know how they managed to do this but I know that in MyBB, class_parser.php is the file regulating this behavior.
Similarly, I want to use a MyCode and when the user adds this around their code, no new lines will be converted to br. Simply put, I want to reverse the nl2br procedure only for this MyCode.
I thought about replacing all br codes inside a MyCode but that would also remove necessary "br" line breaks put there by the user.
Is there any workaround for this?
At the top of the class_parser file, there's a list of options but I couldn't find any of them on Admin CP:
This is the nl2br part in the class_parser file:
Could we do something like, if $message contains "dohtml" then nl2br isn't applied?
Thanks!
I'm running a roleplay forum and the nl2br feature in parsing creates problems when the users want to use HTML templates for their threads.
The coders are from the Jcink platform, where a MyCode "dohtml" exists; when this "dohtml" code is used, new lines are NOT converted to <br>. Jcink isn't open source, so I don't know how they managed to do this but I know that in MyBB, class_parser.php is the file regulating this behavior.
Similarly, I want to use a MyCode and when the user adds this around their code, no new lines will be converted to br. Simply put, I want to reverse the nl2br procedure only for this MyCode.
I thought about replacing all br codes inside a MyCode but that would also remove necessary "br" line breaks put there by the user.
Is there any workaround for this?
At the top of the class_parser file, there's a list of options but I couldn't find any of them on Admin CP:
options = array(
allow_html
allow_smilies
allow_mycode
nl2br
filter_badwords
me_username
shorten_urls
highlight
filter_cdata
This is the nl2br part in the class_parser file:
if(!isset($this->options['nl2br']) || $this->options['nl2br'] != 0)
{
$message = nl2br($message);
// Fix up new lines and block level elements
$message = preg_replace("#(</?(?:html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)\s*<br />#i", "$1", $message);
$message = preg_replace("#( )+(</?(?:html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)#i", "$2", $message);
}
Could we do something like, if $message contains "dohtml" then nl2br isn't applied?
Thanks!