Topic: [SIZE] bbcode tag - How to?

Hello,

I've been asked by several of the members of my board to bring back the capability of changing text size within a post. We used to be able to do that in phpBB with the [SIZE=xx]text[/SIZE] formula, but it doesn't work in punBB. Any suggestions to implement this?

Thanks.

Visit the John Lennon Forum, the kindest of all Lennon's message boards

2 (edited by Mark 2005-11-18 20:49)

Re: [SIZE] bbcode tag - How to?

http://punbb.org/forums/viewtopic.php?id=3565

nice feature called search

Re: [SIZE] bbcode tag - How to?

For your information, I did search, several terms, but probably missed the topic. Thanks just the same.

nice feature called kindness wink

Visit the John Lennon Forum, the kindest of all Lennon's message boards

4 (edited by Kenzi 2006-09-20 17:06)

Re: [SIZE] bbcode tag - How to?

i tried to add the [size] tag and cant get it to work for some reason

here is what mine looks like:

$pattern = array('#\[size=(.*?)](.*?)\[/size\]#',
                 '#\[b\](.*?)\[/b\]#s',
                 '#\[i\](.*?)\[/i\]#s',
                 '#\[u\](.*?)\[/u\]#s',

and the replace is:

$replace = array('<span style="font-size: $1">$2</span>',
             '<strong>$1</strong>'
             '<em>$1</em>',
             '<span class="bbu">$1</span>',

i dont get a parse error it just wont work. any clue as to why? thanks.

Re: [SIZE] bbcode tag - How to?

'#\[size=(.*?)](.*?)\[/size\]#',

to
'#\[size=(.*?)\](.*?)\[/size\]#',

You forgot that slash around the middle tongue

echo "deadram"; echo; fortune;

6

Re: [SIZE] bbcode tag - How to?

awsome, thanks!

7 (edited by deadram 2006-09-20 20:09)

Re: [SIZE] bbcode tag - How to?

Also... to tweak it a bit... look at function "preparse_bbcode"

You can add this to the $a array:
'#\[size=\s*([0-9]*?)\s*\]\s*(.*?)\s*\[/size\]#',

And this to the $b array:
'[size=$1]$2[/size]',

It will remove any extra spaces, including new lines, and tabs. and you might want to watch out for people doing this:

[size=1"><my html code that does bad stuffies :/>]Muhahahahaha[/size]

I would recommend doing your '#\[size=(.*?)\](.*?)\[/size\]#', this way:
'#\[size=([0-9]*?)\](.*?)\[/size\]#',

It's much safer to be exact tongue

echo "deadram"; echo; fortune;

8

Re: [SIZE] bbcode tag - How to?

i think im making things worse sad here is what i got:

preparse:

$a = array( '#\[url=("|\'|)(.*?)\\1\]\s*#i',
                '#\[url\]\s*#i',
                '#\s*\[/url\]#i',
                '#\[email=("|\'|)(.*?)\\1\]\s*#i',
                '#\[email\]\s*#i',
                '#\s*\[/email\]#i',
                '#\[img\]\s*(.*?)\s*\[/img\]#is',
                '#\[colou?r=("|\'|)(.*?)\\1\](.*?)\[/colou?r\]#is',
                '#\[size=\s*([0-9]*?)\s*\]\s*(.*?)\s*\[/size\]#');


    $b = array(    '[url=$2]',
                '[url]',
                '[/url]',
                '[email=$2]',
                '[email]',
                '[/email]',
                '[img]$1[/img]',
                '[color=$2]$3[/color]',
                '[size=$1]$2[/size]');

the rest:

$pattern = array('#\[size=([0-9]*?)\](.*?)\[/size\]#',
                 '#\[b\](.*?)\[/b\]#s',
                     '#\[i\](.*?)\[/i\]#s',
                     '#\[u\](.*?)\[/u\]#s',
                '#\[youtube\]http://www.youtube.com/watch\?v=(.*?)\[/youtube\]#s',
                '#\[googlevid\]http://video.google.com/videoplay\?docid=(.*?)\[/googlevid\]#s',
                     '#\[url\]([^\[]*?)\[/url\]#e',
                     '#\[url=([^\[]*?)\](.*?)\[/url\]#e',
                     '#\[email\]([^\[]*?)\[/email\]#',
                     '#\[email=([^\[]*?)\](.*?)\[/email\]#',
                     '#\[ul\](.*?)\[/ul\]#',
                     '#\[ol\](.*?)\[/ol\]#',
                     '#\[uli\](.*?)\[/uli\]#',
                     '#\[oli\](.*?)\[/oli\]#',
                     '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s',
                     '#\[font=(.*?)](.*?)\[/font\]#',
                     '#\[style="(.*?)"\](.*?)\[/style\]#',
                     '#\[hr /\]#',
                     '#\[hr\]#',
                     '#\[table\](.*?)\[/table\]#',
                     '#\[caption\](.*?)\[/caption\]#',
                     '#\[tr\](.*?)\[/tr\]#',
                     '#\[td\](.*?)\[/td\]#',
                     '#\[s\](.*?)\[/s\]#',
                     '#\[pre\](.*?)\[/pre\]#',
                     '#\[sup\](.*?)\[/sup\]#',
                     '#\[sub\](.*?)\[/sub\]#',
                     '#\[h\](.*?)\[/h\]#');


    $replace = array('<span style="font-size: $1">$2</span>',
                 '<strong>$1</strong>',
                     '<em>$1</em>',
                     '<span class="bbu">$1</span>',
                'object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>',
                '<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=$1&hl=en"></embed>',
                'handle_url_tag(\'$1\')',
                     'handle_url_tag(\'$1\', \'$2\')',
                     '<a href="mailto:$1">$1</a>',
                     '<a href="mailto:$1">$2</a>',
                     '<ul>$1</ul>',
                     '<ol>$1</ol>',
                     '<li>?  $1</li>',
                     '<li>$1</li>',
                     '<span style="color: $1">$2</span>',
                     '<span style="font-family: $1">$2</span>',
                     '<div align="$1">$2</span>',
                     '<span style="$1">$2</span>',
                     '<hr />',
                     '<hr />',
                     '<table>$1</table>',
                     '<tr>$1</tr>',
                     '<td>$1</td>',
                     '<del>$1</del>',
                     '<pre>$1</pre>',
                     '<sup>$1</sup>',
                     '<sub>$1</sub>',
                     '<span style="background-color: #FFFF00; color: #000000">$1</span>');

i'm still not getting a parse error, but size won work using a 1-9 variable.

9 (edited by deadram 2006-09-20 22:21)

Re: [SIZE] bbcode tag - How to?

Gimme a minute, I might as well add size to my bbcode too, lol tongue

EDIT --

add for $a
    '#\[size=("|\'|)([0-9]+?)\\1\](.*?)\[/size\]#is'

add for $b
    '[size=$1$2]$3[/size]'

Then this for $pattern
     '#\[size=([0-9]+?)\](.*?)\[/size\]#is');

And for $replace
      '<span style="font-size: $1%">$2</span>');

The only downside is if someone says [size=1000000]Really uber to big to view text[/size]
some reading on preg_match might find you a way to limit the number of [0-9] matches in $a

echo "deadram"; echo; fortune;

10

Re: [SIZE] bbcode tag - How to?

does my coding look right? i'll be the first to admit im a coding retard.

Re: [SIZE] bbcode tag - How to?

this isn't coding, it's regex matching, or regular expression substiitution. tongue big_smile

echo "deadram"; echo; fortune;