Wiki table markup discussion history

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search
Blue Glass Arrow.svg MediaWiki-2020-logo.svg
A proposal to move this page to MediaWiki.org was rejected.

This feature has been implemented in MediaWiki. Info on how to use it is in the user's guide. The following proposals are archived here for historical and comparative purposes.

Half-HTML proposal[edit]

lacking a better name... (by Magnus Manske)

    {| initiates a table, |} ends it
    {|F starts a table, with formatting "F"
    | starts a table cell with no extra formatting
    |F| starts a table cell with formatting "F"
    |- starts a new row

Simple example[edit]

    {|
    | Cell 1, row 1
    | Cell 2, row 1
    |-
    | Cell 1, row 2
    | Cell 2, row 2
    | Cell 3, row 2
    |}

produces:

Cell 1, row 1 Cell 2, row 1
Cell 1, row 2 Cell 2, row 2 Cell 3, row 2

Simple example with border[edit]

    {| border=1
    | Cell 1, row 1
    | Cell 2, row 1
    |-
    | Cell 1, row 2
    | Cell 2, row 2
    |}

produces

Cell 1, row 1 Cell 2, row 1
Cell 1, row 2 Cell 2, row 2

More complex example[edit]

    {| align=right width=100
    | Cell 1, row 1
    |rowspan=2| Cell 2, row 1 (and 2)
    | Cell 3, row 1
    |-
    | Cell 1, row 2
    |
    | Cell 3, row 2
    |}

produces:

Cell 1, row 1 Cell 2, row 1 (and 2) Cell 3, row 1
Cell 1, row 2 Cell 3, row 2
Here
is
some
random
text
for
table
alignment
my
bad
sorry ^^;

But I'm not sure how the parser will algorithmically go from Magnus' input to the correct HTML output. Note in particular that there is no <td> element corresponding to the input line that is nothing but "|". -- Toby 21:44 Jan 30, 2003 (UTC)

Advantages[edit]

  • Full HTML capabilities, if needed
  • Simple syntax for simple tables
  • Allows for nested tables
  • Could use pre-defined table types via "class=xxx"

List-style proposal[edit]

Example:

[[Table:president]]
||
| Name
| Bill Clinton
||
| Musical instrument
| saxophone
||

The table is made up of two parts:

  • Firstly, a header block. Syntax and tokens to be determined: the use of [[ above is just an example. The header block defines the style of the table. This may be complex and hard to read, and could be one of:
    • CSS
    • something CSS-ish and Wiki-ish
    • keywords which identify build-in styles
  • Secondly, the actual data. Note that "table headers" in the sense of "special rows or columns which define the meaning of the data" are just specially-formatted rows or columns. It's up to the header block to define some sort of highlighting.

Instead of one raw line per table line, chop the table up with one line per cell. This could be an optional feature.

||
| row one, cell 1
| row one, cell 2
||
| row two, cell 1
| row two, cell 2
||

Basically, "|" marks the start of a cell. "||" marks the start of a row. Presumably, one could indicate a skipped cell with

| full cell
|
| we've skipped one

Now the twist: this can work in either direction, eg:

||
| column one, cell 1
| column one, cell 2
||
| column two, cell 1
| column two, cell 2
||

For some tables, this might be a clearer way of reading raw format.

The header block would need to define:

  • whether row or column direction
  • internal borders
  • main border
  • colours

This could be some form of CSS or hideous markup codes, or it could point to styles elsewhere. The examples below are inspired by the [[math: syntax, but it's just off the top of my head.

The point is that no matter how ugly the table head block is, it's ONE line of yuck that can be skipped over by someone who is interested in the data of the table.

[[table: column; border:black]]
|| 
| first cell
...etc

Preset styles might be easier. These could themselves define row / column behaviour. For example, for the information on element pages, phoneme pages and US president pages. Something like the Periodic Table might have to remain in HTML -- but it doesn't need to be updated often. An advantage of using presets would be instant uniformity across similar pages.

[[table:element]]
[[table:phoneme]]
[[table:president]]
and some general styles:
[[table:row_border]]
[[table:column_border]]
[[table:row_lines]]
[[table:column_lines]]
[[table:row_grid]]
[[table:column_grid]]

Extended PikiePikie syntax[edit]

This syntax is designed to allow nested tables, and a limited set of table attributes. The most important differences with the PikiePikie syntax are:

  1. [| and |] start and end a table row not a table
  2. | is used to separate columns
  3. after [| and | you can have attributes such "al=r" (align = "right").

Simple examples:

  [| a simple table | with two columns |]


  [{ first header | second header  }]
  [| a table      | with 2 columns |]
  [| and 2        | rows           |]
  [!    and a caption              !]

  
  [|  a table with a single line  and      |]
  [|
    [| a nested table | with two columns |]
    [| and two        | rows             |]
  |]

A more elaborate example (The Owl table):

  {{bd=1,cs=0,al=r,cp=2}}
  [|{{al=c,bc=pink}}                        ''Owls'''                      |]
  [|                    [[image:Northern_Spotted_Owl.USFWS-thumb.jpg]]     |]
  [|{{al=c}}                        Northern spotted owl                   |]
  [|{{al=c,bc=pink}}          '''[[Scientific classification]]'''          |]
  [|{{al=c}}
    [|    [[Kingdom (biology)|Kingdom]]:      |  [[Animalia]]       |]
    [|    [[Phylum]]:                         |  [[Chordata]]       |]
    [|    [[Class (biology)|Class]]:          |  [[Aves]]           |]
    [|    [[Order (biology)|Order]]:          |  '''Strigiformes''' |]
  |]
  [|{{al=c,bc=pink}}    '''[[family (biology)|Families]]'''                |]
  [|
    [|       [[Barn owl|Tytonidae]] - Barn owls                     |]
    [|       [[Typical owl|Strigidae]] - Typical owls               |]
  |]


Basic principles[edit]

  • [| ... | ... | ... |] indicates a table row
  • [{ ... | ... | ... }] indicates a table header
  • [! ...... !] indicates a table caption
  • {{%arg%}} after | defines attributes for following cell
  • {{%arg%}} after [ defines attributes of table row
  • {{%arg%}} after other than | or [ defines attributes for the following table
  • consecutive rows belong always to the same table, table ends when there is no immediate next row

Allowed Arguments[edit]

  • table:
    • al=align, bc=background-color, bd=border, wd=width,
    • cp=cellpadding, cs=cellspacing
  • table row:
    • al=align, bc=background-color, va=valign
  • table cell:
    • al=align, bc=background-color, cs=col-span, rs=rowspan,
    • va=valign, wd=width

FAQ[edit]

Comparison to the first proposal[edit]

The syntax can be used similar to Tarquin's proposal. You would get something like the following:

  [|
  | row one, cell 1
  | row one, cell 2
  |]
  [|
  | row two, cell 1
  | row two, cell 2
  |]

Some existing schemes below.

MoinMoin Syntax[edit]

Seen on Meatball's patch of UseModWiki too

|| Heading 1 \
|| Heading 2 \
|| Heading 3 \
||
|| I went to the barber today and he gave me a shave and a haircut. \
|| 7 \
|| No bullet lists, though. :( \
||
|| New row \
|||| LinkPattern in a cell that spans two columns. \
||

Wookee syntax[edit]

Seen on the Unreal Wiki

simple table:

| bAlwaysRelevant | Notoriously overconfident.
| bHidden | Lacks self assurance.


complex table:

|||^ <wiki>=== A complex table ===</wiki>        |
|^ '''First'''   |^ '''Second''' |^ '''Third'''  |
|  upper left    |  upper middle | right side    |
|> right aligned |^ centered     |< left aligned |
|||^ bottom row spans three columns              |

On wikitech-l-mailinglist, Jocelyn Giraud also mentioned http://phpwiki.sf.net/phpwiki, which seems to have this Wookee syntax implemented. Also a disadvantage is mentioned: phpwiki's table don't have is "align='right'" on the whole table.

PikiePikie syntax[edit]

[2|| This is a table with a single cell on the first line  ||
||   two cells          || on this line                    ||
||   two cells on       || this line too                   ||
|||> and one centered cell on this line                    |]

This would become:

This is a table with a single cell on the first line
two cellson this line
two cells onthis line too
and one centered cell on this line

For more examples see: http://pikie.darktech.org/cgi/pikie?TableSyntax


Basic principles[edit]

  • [| starts a table and |] ends it
  • || indicates new column
  • ||\n|| indicates new table row

Advantages[edit]

  • Allows nested tables and cells with more than 1 line but keeps visual format for simple tables

Alternative to Tables: Data view objects[edit]

The question that is absent from this page is "why are tables wanted?". WP should steer well clear of using them for blocky kludges to get formatting looking approximately okay on the author's favourite browser (as in HTML). On my reckoning this means that the primary use is to represent data, whether it be a key-value association (common on the sidebars in geographical pages) or larger spreadsheet-style tables of numbers and the like.

Is it possible to have a new type of object (media class?) for data views. On the uploading of a simple flat database, it would be possible to generate tables from this data (select columns to display), and maybe even some simple data transformations (totals, averages -- probably not joins). This could be handled by wiki-type syntax, and would get around the need for general table markup in a large number of cases. The advantage of this is that all the layout markup that pollutes html tables and their wiki reformulations would be kept out of the picture. The tables could easily be made "live" for resorting, hiding cols, etc. The disadvantage is that the data would not be there "on the page", but would require a separate upload/edit (like with images).

The challenge is to make it wikilike, and not kill your database with too many "build this table" queries. AndrewKepert

Key-Value markup[edit]

Just re-reading what I wrote, and thinking a bit more about it. Key-value markup need not reference external tables, it can be inline and much more wiki-like. This type of markup should be far more "WYMIWYG" rather than "WYSIWYG", and the visual layout can be left to the WP engine, stylesheets or whatever. The markup could even be transformed into xml or some table-free stylesheet-based layout without breaking too much. (Or even rendered to a <dl> list for text browsers.) Here is a rough idea of what I am thinking:

CodeAppearance
===Gosford===
{Country} => {[[Australia]]}
{State} => {[[New South Wales]]}
{Location} => {33°22'S 151°20'E}
{Gosford Council Area} => {940.2 km<sup>2</sup>}
{Population (2001)} => {154,654}
{[[Postcodes]]} => {2250, 2251, 2256, 2257, 2260}

Gosford

Country:Australia
State:New South Wales
Location:33°22'S 151°20'E
Gosford Council Area:940.2 km2
Population (2001):154,654
Postcodes:2250, 2251, 2256, 2257, 2260

(yes I know this is ugly as sin -- that is not the point -- css to the rescue)

The actual syntax here is inspired by perl, php, etc associative arrays. There is no overall container for the key-value list, but maybe there would need to be. --AndrewKepert 02:18, 18 Sep 2003 (UTC)


How about just using the definition list markup? Like

State: Queensland
Postcode Cairns 4870
Townsville 4810
<dl class=RightFloat>
; State 
: [[Queensland]]
; Postcode 
: Cairns 4870
Townsville 4810
</dl>

with the dl container to have somewhere to put attributes. For text browsers, it can remain as dl.

This is a great idea! It is simple, straightforward, portable. Well, it is not quite expressive (no way to have a nested-table) but this seems to suffice to our needs. -- Taku 01:17, 24 Nov 2003 (UTC)

Abbi-Syntax[edit]

In my belief in specific cases there is no need for table-like Wiki-Code and a smaller window of opportunity could help to get a standardized layout. Tables are often used in very specific cases, as in "country short information". I believe, a specific code should be defined:

[|type=country|State=United Kingdom|Inhabitans=60,123 Million|CoatOfArms=UK_Coat_Of_Arms.png|OfficialLanguage=None. [[English]] is de facto; Welsh and Scottish Gaelic have equal status with English in Wales and Scotland respectively (see Languages in the United Kingdom).|]

This would look as in the table in United Kingdom, and missing attributes would lead to missing table cells.

Every specific attribut can be pre-defined and the programmer arranges the attribut's layout centrally. For instance the state name automatically could be bold, while the Images alt- and table-Text automatically could be the State's Name.

Additionally an other syntax for other tables than these specific ones, could be defined as proposed above. [

Abbi's birthday syntax[edit]

Similar to the solution presented above, the birth and death dates and places could be added like this, using

type=biography:[|type=biography|PlaceOfBirth=London|PlaceOfDeath=[[New York]]|DateOfBirth=12 April 1978|DateOfDeath=1 January 2030|]

which will lead to:

(April 12, 1978 in London - January 1, 2030 in New York)

in the English Wikipedia version and i.e. to (geb. am 12. April 1978 in London, gest. am 1. January 2030 in New York) in the German Wikipedia version. Easy the syntax can be moved to other Wikipedia versions which automatically know how to display the data in the particular language. Additionally, when I change of the style is required, all changes will occur in all biographies using this syntax.