PDA

View Full Version : <pre> Problems


GCSkye
03-09-2009, 05:24 AM
I added the following BBCode to my site:

Title: Pre
Name: pr
Replacement: <pre>{param}</pre>

The same bb code is used here at vbulletin.org as well. Problem is when I hit enter it adds 2 spaces. When I type (without *):

[*pre]test
test[*/pre]

It comes out as:

test
test

Is there a way to remove that second gap it creates?

GCSkye
03-10-2009, 08:22 PM
Any solution?

TigerC10
03-11-2009, 07:36 AM
First of all, the BBCode you should be using is [noparse]... Any bbcode in that tag will not be parsed/translated into what it's actually supposed to be.

test
test

See? No silly * symbols to make things ugly. Next, you must have typoed your replacement, it should be:

Replacement: <pre>{param}</pre>




Now then, this issue comes from the "cleaning" that vBulletin does on outputting your stored data. See, vBulletin stores the line breaks in your posts with a \n character. The character is then translated into <br \> upon output - and in the source code vBulletin will insert a newline character after the <br \> so that the actual viewable source code on the page is pretty.

Your pre tag catches that <br \> html that vBulletin outputs and correctly outputs a newline. Then it catches the newline after the <br \> and outputs another newline. Can you dig it?


Anyway, without implementing a plugin or a change in the .php file source code - there is no way to resolve this issue. Although, a few (http://www.vbulletin.com/forum/showthread.php?t=231990) people (https://vborg.vbsupport.ru/showthread.php?p=1721294) explain that they've been able to achieve more desirable results with a different replacement value...


<code style="white-space: pre">{param}</code>

or...

<div style="white-space:nowrap; width:300px; overflow:scroll;"><code>{param}</code></div>



According to them, this replacement value works properly in firefox, but not in internet explorer. I haven't tested it... But you're welcome to attempt it.

GCSkye
03-11-2009, 10:25 PM
Thx for noparse idea ^ _^

I got the whole thing about vbauto adding the <br /> but thanks for that. I tried the other commands with no luck in google chrome. The first one may show promise in ff but the second only messes things up.

This is a matter that doesn't bother me to much. Thanks for you help.