Topic: Custom BBCode.

K, So im trying to get Geshi working with punbb, ive been sitting here awhile, trying to get it working. But everything gets stripped out, by the time it gets "processed", my;

[autoit]MsgBox(0, "Hello", "World")[/autoit]

turns into

MsgBox(0, "Hello", "World")

When it should be;
Like: http://code.spartan-ware.com/include/test.php

Should be like that. But all the html is getting stripped out.
Any ideas?

<?
include "geshi.php";
$geshi = @new GeSHi("MsgBox(0, 'hello', 'world')", "autoit", getcwd());
$text = $geshi->parse_code();
echo $text;
?>

Theres the test.php example.

2

Re: Custom BBCode.

Anyone?

Re: Custom BBCode.

If you're running that outside of the parser, the HTML is going to be sanitized for obvious reasons./

4

Re: Custom BBCode.

I got it working, Kinda.
I figured out how to get it working, But getting the string is the harder part.

So, theres

    $pattern = array('#\[b\](.*?)\[/b\]#s',
                     '#\[autoit\](.*?)\[/autoit\]#s',
                     '#\[i\](.*?)\[/i\]#s',
                     '#\[u\](.*?)\[/u\]#s',
                     '#\[url\]([^\[]*?)\[/url\]#e',
                     '#\[url=([^\[]*?)\](.*?)\[/url\]#e',
                     '#\[email\]([^\[]*?)\[/email\]#',
                     '#\[email=([^\[]*?)\](.*?)\[/email\]#',
                     '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s');

    $replace = array('<strong>$1</strong>',
                     '$1',
                     '<em>$1</em>',
                     '<span class="bbu">$1</span>',
                     'handle_url_tag(\'$1\')',
                     'handle_url_tag(\'$1\', \'$2\')',
                     '<a href="mailto:$1">$1</a>',
                     '<a href="mailto:$1">$2</a>',
                     '<span style="color: $1">$2</span>');

In the replace for the '$1' I want it to be the;
    $geshi = @new GeSHi("$1", "autoit", getcwd()."/include");
    $geshi->parse_code();
But cant figure out how.

Re: Custom BBCode.

make a function, like is done for the URL tags, parse in there and return the parsed value.

6

Re: Custom BBCode.

Im confused.

Re: Custom BBCode.

Look at how URL BBCode is handled in the code you just pasted. Emulate that.

8 (edited by Azkay 2008-03-21 15:08)

Re: Custom BBCode.

Kay, Ive gotten this far

    $pattern = array('#\[b\](.*?)\[/b\]#s',
                     '#\[autoit\](.*?)\[/autoit\]#e',
                     '#\[i\](.*?)\[/i\]#s',
                     '#\[u\](.*?)\[/u\]#s',
                     '#\[url\]([^\[]*?)\[/url\]#e',
                     '#\[url=([^\[]*?)\](.*?)\[/url\]#e',
                     '#\[email\]([^\[]*?)\[/email\]#',
                     '#\[email=([^\[]*?)\](.*?)\[/email\]#',
                     '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s');

    $replace = array('<strong>$1</strong>',
                     'handle_au3_tag(\'$1\')',
                     '<em>$1</em>',
                     '<span class="bbu">$1</span>',
                     'handle_url_tag(\'$1\')',
                     'handle_url_tag(\'$1\', \'$2\')',
                     '<a href="mailto:$1">$1</a>',
                     '<a href="mailto:$1">$2</a>',
                     '<span style="color: $1">$2</span>');
function handle_au3_tag($text)
{
    $geshi = @new GeSHi($text, "autoit", PUN_ROOT."/include");
    $text = $geshi->parse_code();
    return $text;        
}

And it turns out like this;
http://code.spartan-ware.com/viewtopic.php?id=2

If I use double quotes between the [autoit][/autoit] it comes out with the first post in that thread.
If I use single quotes between the [autoit][/autoit] it comes out fine. ( Second post ).

Any ideas?

Re: Custom BBCode.

I don't know how GeSHi works, but my assumption is that it's the result of a double escaping via htmlspecialchars.
Try

FIND

$geshi = @new GeSHi($text, "autoit", PUN_ROOT."/include");

REPLACE WITH

$geshi = @new GeSHi(html_entity_decode($text), "autoit", PUN_ROOT."/include");

10

Re: Custom BBCode.

Mmmm. Perfect.
Thanks alot :3

11

Re: Custom BBCode.

Hmm, Seems like a new problem.
http://code.spartan-ware.com/viewtopic.php?id=3

If theres a new line, It breaks?

Re: Custom BBCode.

Check out preparse_bbcode, I think you'll need to add your stuff there.

13

Re: Custom BBCode.

Bah, Cant figure it out. D;