Tags:
create new tag
, view all tags
Hi. I had a need to create left aligned table headers, and quickly found out that the Twiki shorthand didn't support it. Simply created a new shorthand, so that if it is a table header and more space to the right than to the left, it left-aligns it (very similary to right align mechanism). Was an easy fix, so thought I'd post the changes I made (including changes to doc):

TWiki.pm

--- c:\TwikiOrig\lib\TWiki.pm   Fri Sep 14 23:44:42 2001
+++ c:\twiki20010901\lib\TWiki.pm       Mon Mar  4 17:30:40 2002
@@ -1571,6 +1571,13 @@
                 $attr .= ' align="center"';
             }
         }
+
+        if( $l1 <= 1) {
+            if( $l2 >= 2) {
+                $attr .= ' align="left"';
+            }
+        }
+
         if( /^\s*(\*.*\*)\s*$/ ) {
             $text .= " $1 ";
         } else {

TextFormattingRules.txt


c:\twikiOrig\data\TWiki\TextFormattingRules.txt Mon Sep 17 18:12:46 2001

+++ c:\twiki20010901\data\TWiki\TextFormattingRules.txt Mon Mar 4 17:25:20 2002

@@ -244,6 +244,7 @@

Table:
Optional spaces followed by the cells enclosed in vertical bars.
Note: | *bold* | cells are rendered as table headers.
+__Note:__ | spaced    | cells are rendered left aligned (even headers).
Note: |   spaced  | cells are rendered center aligned.
Note: |     spaced | cells are rendered right aligned.
Note: | 2 colspan || cells are rendered as multi-span columns.

Could someone apply the patch please?

-- DavidHay - 04 Mar 2002

I run into the same problem a few times. TWiki actually doesnot generate center align for headings, this is the default behaviour of browsers. Your solution is overriding this behaviour.

One small problem with this fix is that it breaks existing content where tables are entered with justified columns, e.g.

| *First*   | *Second* | *Third*    |
| aa aaa aa | bb       | cc         |
| dddd      | eee      | ffff fffff | 

In this example First and Third would be left aligned, Second centered.

Opinions if this should go into the core?

-- PeterThoeny - 07 Mar 2002

Perhaps it's a bit late to mention this, but the syntax for left/center/right adjustment wasn't clear from the examples. I gather that using spaces controls justification?

How about using something like |~heading| for left, |~heading~| for center and |heading~| for right (with |heading being defaulted to left - but |heading~ would have to be matched first, or no default at all and headings are auto bolded)?

-- DavidLeBlanc - 17 Mar 2002

It is now possible to create left aligned header cells with the latest TablePlugin.

-- PeterThoeny - 17 Mar 2002

From the TablePlugin page, it looks as though header alignment is only on a per-web basis? What if you want some headers aligned differently, even on the same table?

-- DavidLeBlanc - 17 Mar 2002

This is per table. It resets to the default at the end of each table.

-- PeterThoeny - 17 Mar 2002

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2002-03-18 - 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.