MyBB Community Forums

Full Version: modify line breaks only in certain tags
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So we modified a syntax highlighter codebox to do what we want. However there are html linebreaks after each line like so
[attachment=37537]
in attempt to fix this in class_parser.php we commented out the section that adds line breaks like this
       //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("#(&nbsp;)+(</?(?:                                                   html|head|body|div|p|form|table|thead|tbody|tfoot|tr|td|th|ul|ol|li|div|p|blockquote|cite|hr)[^>]*>)#i", "$2", $message);
       //}
but then you lose ALL the line breaks in the entire post and its all just mushed together, except the codebox as we want without line breaks
So my question is, is there some template conditional or something else we can do to remove linebreaks from the code box only.

This is the BBCode we made to insert that codebox syntax higlhighter

[pre class="brush: python"]
print('hello world')

print("test")
[/pre]
IS there a way to not put line breaks in between these pre tags BBCode's but everywhere else?