MyBB Community Forums

Full Version: Preformatted Text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This comes from the fact that many of the boards that MyBB supports for Merging from use the [pre][/pre] BBCode version of the html <pre></pre> tags, and MyBB should have it as well.

Implements: [pre]Preformatted Text[/pre]

To add this tag to MyBB go to your MyBB Admin CP->Configuration->MyCode and select the Add New MyCode tab at the top of the page.

Title: Preformatted Text

Short Description: Implements the html Preformatted Text (<pre>text</pre>) as a MyCode ([pre]text[/pre])

Regular Expression: [pre](.*?)[/pre]

Replacement: <pre>$1</pre>

Parse Order: 1
Great idea. I'm surprised I didn't think of it first. lol
I believe the regular expression should be \[pre\](.*?)\[/pre\] though.
You are correct, sorry I forgot to escape them. I was getting ready to rush out the door lol. I trusted the community to catch any mistakes though. Smile
Thank you, the code is useful in certain cases Big Grin but i may add that just simple <pre>$1</pre> will break the layout for it will run over with long text. It needs wrapping and I think this is better:

<pre style="
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-wrap;
word-wrap: break-word;
">$1</pre>

Code took from http://forums.techguy.org/web-design-dev...-wrap.html
What would be better is if I allowed adding options into the opening MyCode tag actually (For advanced users); but yes, those options are good.