Tags:
create new tag
view all tags

SID-01876: Table formatting bewilderment

Status: Unanswered Unanswered TWiki version: 6.0.0 Perl version:
Category: CategoryEditing Server OS: Last update: 10 years ago

I have long been bewildered by the alignment options in TWiki tables.

The text in TextFormattingRules is quite clear:

| center-aligned | cell with at least two, and equal number of spaces on either side | right-aligned %VBAR cell with more spaces on the left

It never works for me. Turns out, it is wrong. I went to the source and discoverd that the documentation is confused - I'm just collateral damage. I'd bet that my experience is typical.

The actual Perl code is:

        if (/^(\s*).*?(\s*)$/) {
            $l1 = length($1);
            $l2 = length($2);
        } 
        if ( $l1 >= 2 ) {
            if ( $l2 <= 1 ) {
                $attr->{align} = 'right';
            }
            else {
                $attr->{align} = 'center';
            }

Thus: The default is no explicit alignment (= left).

If the number of spaces on the left is 2 or more, alignment will be added. In that case, if the number of spaces on the right is two or more, centered. Otherwise right.

The rules are written very differently. "at least two and equal number on either side" is not what this code does. Nor does it decide based on "more spaces on the left", at least not if the right has more than two.

I've always ended up frustrated and used TablePlugin, as I'd try 3 on the left and 2 on the right, expecting 3 > 2 => right-justify, but I get centered.

The doc is clear. The code is wrong. What the code actually does is much arder to explain than what the doc specifies. But fixing this will probably break a lot of tables in the field.

Best approach is probably to say: one on each side = default (left) two on left, one on right = right-aligned two on left ,two on right = center

And anything else is undefined.

And someone owes me a lot of chocolate1 for suffering this long, and for documenting the actual behavior.

1 Specifications will be provided when the guilty party is identified.

-- Timothe Litt - 2014-02-22

Discussion and Answer

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- Peter Thoeny - 2015-12-03

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Unanswered
Title Table formatting bewilderment
SupportCategory CategoryEditing
TWiki version 6.0.0
Server OS

Web server

Perl version

Browser & version

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2015-12-03 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.