News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

New BBcode ( Alternate [code] )

Started by [SAP]Francis, November 17, 2007, 07:56:08 AM

Previous topic - Next topic

Kays

The only way I can get it to work properly is by adding a space after the pound sign. Weird

That's it for me. I've got to work tomorrow so I'm off to bed.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

[SAP]Francis

But since PAWN is a coding language, it will **** it up. Ok, I'll keep #... in black, that's not so important. I even don't know how can I thank you. Give me ideas, maybe I'll accept.

Vehicles Forum

Founded By Francis Morissette

Kays

Finally figured that problem out. Should of done a View Source earlier. I cheated a little to get around it. :)

Not quite happy with it yet and will play with it a bit more. One of the things which will happen is if a word which is highlighted blue is ued in a comment or elsewhere, it will be blue in colour. For, if else, elseif and while can be vlalidated by checking for the opening brace "(". But not the rest unless what's inside a set of quotes can be identified. I don't know how far I'll get on it though.

But here's what I've got so far.


$data = str_replace(
array(
\'public\',
\'return\',
\'sizeof\',
\'switch\',
\'true\',
\'false\',
\'if\',
\'new\',
\'else\',
\'for(\',
\'while\',
\'(\',
\')\',
\'[\',
\']\',
\'{\',
\'}\',
\''\'
),
array(
\'<span style="color: blue;">public</span>\',
\'<span style="color: blue;">return</span>\',
\'<span style="color: blue;">sizeof</span>\',
\'<span style="color: blue;">switch</span>\',
\'<span style="color: blue;">true</span>\',
\'<span style="color: blue;">false</span>\',
\'<span style="color: blue;">if</span>\',
\'<span style="color: blue;">new</span>\',
\'<span style="color: blue;">else</span>\',
\'<span style="color: blue;">for</span>(\',
\'<span style="color: blue;">while</span>\',
\'<span style="color: red;">(</span>\',
\'<span style="color: red;">)</span>\',
\'<span style="color: red;">[</span>\',
\'<span style="color: red;">]</span>\',
\'<span style="color: red;">{</span>\',
\'<span style="color: red;">}</span>\',
\'|||\'
), $data);

$data = preg_replace(
array(
\'~#(.+?)\<br \/>~is\',
\'~\/\/(.+?)\<br \/\>~i\',
\'~\/\*(.+?)\*\/~i\'
),
array(
\'<span style="color: blue;">#$1<br /></span>\',           
\'<span style="color: green;">//$1<br /></span>\',
\'<span style="color: green;">/*$1*/</span>\'
), $data);
$data = str_replace(\'|||\', \'&#039;\', $data);

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

[SAP]Francis

#23
This doesn't work for now. It just ****s up everything.
Example: "true = color: blue">true"

Francis

Vehicles Forum

Founded By Francis Morissette

Kays

That's strange. It works fine for me.
http://www.kayssplace.com/boards3/index.php?topic=3.0

Here's all of it
array(
'tag' => 'pawn',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['pawn'] . ':</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',
'validate' => create_function('&$tag, &$data, $disabled', '
                global $context;

if (!isset($disabled[\'pawn\']))
{

$data = str_replace(
array(
\'public\',
\'return\',
\'sizeof\',
\'switch\',
\'true\',
\'false\',
\'if\',
\'new\',
\'else\',
\'for(\',
\'while\',
\'(\',
\')\',
\'[\',
\']\',
\'{\',
\'}\',
\''\'
),
array(
\'<span style="color: blue;">public</span>\',
\'<span style="color: blue;">return</span>\',
\'<span style="color: blue;">sizeof</span>\',
\'<span style="color: blue;">switch</span>\',
\'<span style="color: blue;">true</span>\',
\'<span style="color: blue;">false</span>\',
\'<span style="color: blue;">if</span>\',
\'<span style="color: blue;">new</span>\',
\'<span style="color: blue;">else</span>\',
\'<span style="color: blue;">for</span>(\',
\'<span style="color: blue;">while</span>\',
\'<span style="color: red;">(</span>\',
\'<span style="color: red;">)</span>\',
\'<span style="color: red;">[</span>\',
\'<span style="color: red;">]</span>\',
\'<span style="color: red;">{</span>\',
\'<span style="color: red;">}</span>\',
\'|||\'
), $data);

$data = preg_replace(
array(
\'~#(.+?)\<br \/>~is\',
\'~\/\/(.+?)\<br \/\>~i\',
\'~\/\*(.+?)\*\/~i\'
),
array(
\'<span style="color: blue;">#$1<br /></span>\',           
\'<span style="color: green;">//$1<br /></span>\',
\'<span style="color: green;">/*$1*/</span>\'
    ), $data);
    $data = str_replace(\'|||\', \''\', $data);

// Older browsers are annoying, aren\'t they?
if ($context[\'browser\'][\'is_ie4\'] || $context[\'browser\'][\'is_ie5\'] || $context[\'browser\'][\'is_ie5.5\'])
$data = str_replace("\t", "<pre style=\"display: inline;\">\t</pre>", $data);
elseif (!$context[\'browser\'][\'is_gecko\'])
$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
}'),
'block_level' => true,
),

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

[SAP]Francis

#25
With this, my forum is now only a white page. -.-

Help me!

http://francismori7.hyperphp.com/seifforum

EDIT: It seems that only the main page does it.

http://francismori7.hyperphp.com/seifforum/index.php?board=4.0

EDIT2: Works again, but not with your code... Only works when I put the old one you gave me.

Vehicles Forum

Founded By Francis Morissette

Kays

Yet I don't have a problem with my test boards. Since I can't see what the problem is. Just use it as is and let's forget about any improvements.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

[SAP]Francis

Okay, I found a way to enable [color] in [pawn]. Thanks for everything you made for me!!!!!!!!!!!

Francis

Vehicles Forum

Founded By Francis Morissette

Kays

Good I'm glad you got something to work. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

[SAP]Francis


Vehicles Forum

Founded By Francis Morissette

Kays

Lol, I didn't have notification on. Thanks. :D

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

[SAP]Francis

Quote from: Kays on November 19, 2007, 09:34:21 PM
Lol, I didn't have notification on. Thanks. :D
No problem. You deserve it!

Vehicles Forum

Founded By Francis Morissette

[SAP]Francis

Kays, is it possible to make it compatible on 2.0 beta 3? Thanks.

Vehicles Forum

Founded By Francis Morissette

DarK TeaM PT

yeps because i dont know how to add the one PAWN buttom the tags are working but

this

'quote' => array('code' => 'quote', 'before' => '
Quote', 'after' => '
', 'description' => $txt[260]),

i think isnt anymore implemented on 2.0 RC3 i didnt find it on posts template any guy know how can i do

[SAP]Francis


Vehicles Forum

Founded By Francis Morissette

DarK TeaM PT

yep i know and i already fixed but i have other problem its when we post long Scripts on 1.x versions it automaticly does on the right side the buttom to roll down or up but on 2.0 RC3 not and it does LOOONG Topics... if anyone know the solution please say and btw if there´s code for 2.0 Please send me link or post here i will be thanking so much

[SAP]Francis

There is no code for 2.0 and I will not support it anyways.

Vehicles Forum

Founded By Francis Morissette

Seif

Quote from: DarK TeaM PT on March 17, 2010, 02:33:08 PM
yep i know and i already fixed but i have other problem its when we post long Scripts on 1.x versions it automaticly does on the right side the buttom to roll down or up but on 2.0 RC3 not and it does LOOONG Topics... if anyone know the solution please say and btw if there´s code for 2.0 Please send me link or post here i will be thanking so much
Put it inside a div with overflow on scroll. Other than that, it works fine on SMF 2. Only problem so far is the #. It will make it blue but if the next line also has #, it will be black, but the line after will be blue if you use # again. Still trying to fix the problem.

[SAP]Francis


Vehicles Forum

Founded By Francis Morissette

Seif


Advertisement: