Customizing SMF > SMF Coding Discussion

BBCode tag will not accept 2 digits

(1/1)

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:


--- Code: ---     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' => '',
),
--- End code ---

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(:


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

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

--- Code: ---[1-9]\d*
--- End code ---
(\d means [0-9]) Or, you can specify a maximum value. Say 2-20:

--- Code: ---([2-9]|1\d|20)
--- End code ---
etc. Study other tags that permit limited integer ranges, such as [size].

Nimras:
Thank you so much when i chanted this:


--- Code: ---'test' => '[0-9]\]',
--- End code ---

To this:


--- Code: ---'test' => '([1-9]|\d|)',
--- End code ---

did it seem to work thank you very much.

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

Navigation

[0] Message Index

Go to full version