Jump to content

Wikipedia talk:Table: namespace and editor

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Fredrik (talk | contribs) at 17:01, 12 March 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Less difficult to learn and hard to remember markup; more usability. The current table markup is harder to use than it needs to be.

Maybe something like the following:

<table>
City            Population   Area                               Something
[[Stockholm]]   761,721      188 [[square kilometre|km&sup2;]]  Foo
[[Gothenburg]]  478,055      451 [[square kilometre|km&sup2;]]  -
[[Malmö]]       267,171      156 [[square kilometre|km&sup2;]]  Bar
</table>

which of course would be converted to this:

City Population Area Something
Stockholm 761,721 188 km² Foo
Gothenburg 478,055 451 km²
Malmö 267,171 156 km² Bar

(For reference, here's the quick Python script I wrote to convert it to the existing table markup:)

def tablify(src):
    o = []
    o.append("{| {{prettytable}}\n")
    for line in open(src).readlines():
        row = filter(len, [x.strip() for x in line.split("  ")])
        if not row:
            continue
        o.append("|-\n")
        for cell in row:
            if cell == "-":
                cell = ""
            o.append("| " + cell + "\n")
    o.append("|}")
    return "".join(o)

Some more syntax would of course be needed so you could set style attributes and create cells that span more than one column. Fredrik | talk 15:52, 12 Mar 2005 (UTC)

Well there's already pipe syntax, which shortens the code, but doesn't really improve much on usability for newcomers, because it still uses the HTML table concept. ("What's a header?")
Also, how does yours handle cell styles, headers, spanning rows/columns, background colors, etc? - Omegatron 16:25, Mar 12, 2005 (UTC)

Spanning columns and headers could be done this way (for example):

A   B   C   D
=============
0   1   2   3
4   [-  5  -]

E   F   G   H
=============
6   7   -   8
9   10  11  12
A C D E
0 1 2 3
4 5
E F G H
6 7 8
9 10 11 12

Style settings for individual cells would be difficult -- you pretty much need a delimiter-based syntax (for example using pipes) for that. It could be done by placing it in front of the cell data, like this: |align:center| 5 or |highlight align:center| 5. That way, a complexly formatted table would still require complex code, but the common case would be simple :)

It would, by the way, be nice to have per-column properties by adding a line at the top (this is one feature the current table syntax is missing):

column style: align:left   align:center highlight    align:right   align:left width:230px

- Fredrik | talk 17:01, 12 Mar 2005 (UTC)