PDA

View Full Version : Hand coding custom BB code


Forgott3n
01-22-2009, 03:35 AM
Hello,

I need to create a clone of [code] by editing the vbulletin files.

We are currently trying to create custom BB code that will parse its contents with white-spacing and fixed width (similar to [code] tag). This is how we do it using the admincp custom bb code menu:

<pre style="font-family:"Courier New", Courier, monospace !important;"> Your tabs here </pre>

However, the WYSIWYG editor still adds <br> tags to every new line, resulting in twice as many new lines as we need:

<pre style="font-family:"Courier New", Courier, monospace !important;">

Lorum ipsum<br>
dolor ist

</pre>

shows as:

Lorum ipsum

dolor ist

So how do I "carbon-copy" [code] but change the name to [chords] and change it's div width?

Thanks!

[EDIT] Just to add, I know next to nothing about how vBulletin uses "hooks" and "callbacks". I know PHP 4, but not too familiar with PHP 5's OOP. I am currently looking at

https://vborg.vbsupport.ru/showthread.php?t=200769

for help.

Vaupell
01-22-2009, 01:39 PM
well if <br> dosent work for me i would usually try something entirely different..
<p></p> perhaps.. <br /> same as <br> but for sometimes it changes something.

just a few suggestions. wouldnt know, just experiment.

Digital Jedi
01-22-2009, 02:02 PM
Wouldn't this as a custom BBCode essential do the same thing:

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

Forgott3n
01-22-2009, 02:35 PM
Wouldn't this as a custom BBCode essential do the same thing:

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

Unfortunately not, vBulletin still adds a <br> for every new line. As a result the browser makes a newline for every <br> AND every newline in <code>

This is why I need to hard code it in vBulletin so I can override the nl2br part of the bbcode

Digital Jedi
01-22-2009, 02:39 PM
So your saying that it converts the literal posting of a <br /> tag into an actual carriage return?

Forgott3n
01-22-2009, 03:00 PM
So your saying that it converts the literal posting of a <br /> tag into an actual carriage return?

I'm saying that it converts the literal posting of a new line into a new line AND a <br /> tag. This means I get an extra new line (twice as many) for every time I press enter.

So in the WYSIWYG editor:


Lorum ipsum
dolor ist


The result shows up like on the page:


Lorum ipsum

dolor ist


And the source code shows:


<pre>
Lorum ipmsum<br />
dolor ist
</pre>


<pre> tags will literally take new lines in source and parse them, as well as <br /> tags. Resulting in double spacing.

Digital Jedi
01-22-2009, 03:13 PM
So if I'm understanding your right, you don't mind the breaking space, as long as it doesn't double it up.

If that's the case, I think pre, whether you use CSS or the HTML tag, automatically double spaces lines. I tried this and got the results I believe your looking for:

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