News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

BBCode tag will not accept 2 digits

Started by Nimras, March 18, 2012, 08:13:17 PM

Previous topic - Next topic

Nimras

I finally made my own BBCode Table tag where TD and TH can be used better.

I can now tell it how many tables this one uses.

My problem is as soon i go beyon =9 will it not work it can't accept =10 what so ever.

What have i missed since other BBCode tags accept bigger numbers what have i done wrong?

These are the 2 new codes i added that works in Subs.php:

     array(
'tag' => 'td',
        'type' => 'unparsed_equals',
        'test' => '[0-9]\]',
'before' => '<td colspan="$1">',
'after' => '</td>',
'require_parents' => array('tr'),
'trim' => 'outside',
'block_level' => true,
'disabled_before' => '',
'disabled_after' => '',
),
      array(
'tag' => 'th',
        'type' => 'unparsed_equals',
        'test' => '[0-9]\]',       
'before' => '<th colspan="$1">',
'after' => '</th>',
'require_parents' => array('tr'),
'trim' => 'outside',
'block_level' => true,
'disabled_before' => '',
'disabled_after' => '',
),


I also had to stop Subs-Post.php from doing its checkup on tables only thing left there is the make sure everything is lower case.

in Subs-Editor.php i just added a copy of the td part to add th under    // The final bits are the easy ones - tags which map to tags which map to tags - etc etc.
   $tags = array(:

'~<(th)\s[^<>]*?colspan="?(\d{1,2})"?.*?' . '>~ie' => 'str_repeat(\'[th][/th]\', $2 - 1) . \'[th]\'',
'~<(th)(\s(.)*?)*?' . '>~i' => '[th]',
'~</(th)>~i' => '[/th]',


So anyone has a idea why it will not take more than 1 digit?

Because i have a table where the first should fill 11 fields but i can't because it will not accept 2 digits.

MrPhil

The "regular expression" [0-9] says "require one digit selected from the set 0 through 9". That's your problem: you permit only one digit. Also note that a value of 0 is allowed, but you probably don't want that in a colspan. Assuming that you want to allow 1 through some large number, use
[1-9]\d*
(\d means [0-9]) Or, you can specify a maximum value. Say 2-20:
([2-9]|1\d|20)
etc. Study other tags that permit limited integer ranges, such as [size].

Nimras

Thank you so much when i chanted this:

'test' => '[0-9]\]',

To this:

'test' => '([1-9]|\d|)',

did it seem to work thank you very much.

I hope it will stay this way we will see until then problem solved.

Advertisement: