Wiki table markup discussion history

From Meta, a Wikimedia project coordination wiki
This is an archived version of this page, as edited by Magnus Manske (talk | contribs) at 20:46, 24 January 2003 (class). It may differ significantly from the current version.

Wiki markup for tables. Holy grail of wiki...

Table markup needs to be

  • easy to read in raw form (current HTML is terrible here)
  • flexible to provide borders, colours etc (although maybe pages like the Elements are using those simply because it's possible -- would we miss whistles and bells?)

Half-HTML proposal

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

| starts a table cell with no extra formatting
|F| starts a table cell with formatting "F"
|- starts a new row

Simple example

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

Mor comlex example

| Cell 1, row 1
|colspan=2| Cell 2, row 1 (and 2)
| Cell 3, row 1
|-
| Cell 1, row 2
|
| Cell 3, row 2
|}

Advantages

  • 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

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]]



-- Tarquin


Extended PikiePikie syntax

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 rule, 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

  • [| ... | ... | ... |] indicates a table row
  • [{ ... | ... | ... }] indicates a table header
  • [! ...... !] indicates a table caption
  • Template:%arg% after | defines attributes for following cell
  • Template:%arg% after [ defines attributes of table rule
  • Template:%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

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

FAQ

Comparison to the first proposal

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 ]

Why only these arguments?

These are the ones that were used in the complex tables I saw. Other might be added though, although we should limit it to only those with simple arguments to avoid parsing problems.

-- Jan Hidders



Some existing schemes below.

MoinMoin Syntax

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

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

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

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 centred cell on this line

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


Basic principles

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

Advantages

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