Search:

Categories


Help & Info


 
Knighthawk Armory
 

Table Directives

There are four directives for table processing. All must be at the beginning of a line to have any effect.

(:table (attr...):)

Generates a new HTML <table> tag with the attributes provided in attr.... Closes the previous table, if any. Valid attributes and values are:

  • border (a positive integer)
  • bordercolor (a color name or hex number; doesn't display in all browsers)
  • cellspacing (a positive integer indicating the space between cells)
  • cellpadding (a positive integer indicating the interior border of a cell)
  • width (a positive integer or percent)
  • bgcolor (a color name or hex number)
  • align (left, center or right)
  • summary (does not display; used primarily to help visually disabled people navigate)

(:cell (attr...):)

Generates a new cell with the attributes given by attr.... Closes the previous table cell, if any. In HTML, this creates a new "<td attr>" tag (and possibly <table>, <tr>, and </td> tags if they are needed to produce a valid HTML table).

Note: Placing a space after the cell markup "(:cell:) " causes subsequent text on that line to be treated as preformatted text.

Valid attributes and values are:

  • align (left, center or right)
  • valign (top, middle or bottom)
  • colspan (a positive integer)
  • rowspan (a positive integer)
  • bgcolor (a color name or hex number)
  • width (a positive integer or percent)

(:cellnr (attr..):)

Generates a new cell at the beginning of the next row. Closes the previous table cell, if any. In HTML, this creates a "<tr><td attr>" tag, and possibly <table>, </td>, and </tr> tags if they are needed for valid HTML. Valid attributes and values are:

  • align (left, center or right)
  • valign (top, middle or bottom)
  • colspan (a positive integer)
  • rowspan (a positive integer)
  • bgcolor (a color name or hex number)
  • width (a positive integer or percent)

(:tableend:)

Closes the previous table cell and closes off any table. Generates </td>, </tr>, and </table> tags as needed.

Notes

For the table, cell, and cellnr tags the author can specify any attributes that would be valid in the HTML <table> or <td> tags. Thus you can specify rowspan, colspan, etc. arguments to build arbitrary tables. However, it's not possible to nest a (:table:) inside of a (:cell:) or (:cellnr:) -- the next paragraph explains why.

Example 1. A table using table directive markup.

(:table border=1 cellpadding=5 cellspacing=0:)
(:cell:) a1
(:cell:) b1
(:cell:) c1
(:cell:) d1
(:cellnr:) a2
(:cell:) b2
(:cell:) c2
(:cell:) d2
(:tableend:)
a1 b1 c1 d1
a2 b2 c2 d2

In HTML, this is the same as

<table border='1' cellpadding='5' cellspacing='0'>
  <tr>
    <td>a1</td>
    <td>b1</td>
    <td>c1</td>
    <td>d1</td>
  </tr>
  <tr>
    <td>a2</td>
    <td>b2</td>
    <td>c2</td>
    <td>d2</td>
  </tr>
</table>

Floating Table with bulleted navigation list

Navigation Links

What if you wanted to create a nice little table like a table of contents in a page like this? In this example, the table is floating right and contains some links in a bulleted list. This is a nice demonstration of how it's possible to build a little table of contents in the page, which might navigate to other pages just within the same wiki group. Note that having a bulleted list won't work in a ordinary table - it only works inside an table created with table directives such as the example code used here.

(:table border=1 width=30% align=right bgcolor=#cccc99 cellspacing=0 :)
(:cellnr:)
'''Navigation Links'''
(:cellnr:)
*[[Tables]]
*[[Table directives]]
(:tableend:)

Navigation Links

(:table border=1 width=30% align=right bgcolor=#cccc99 cellspacing=0 :)
(:cellnr colspan=2 align=center:)
'''Navigation Links'''
(:cellnr align=center:)
[[Tables]]
(:cell align=center:)
[[Table directives]]
(:tableend:)

Navigation Links

Tables

Table directives

Looking at the markup here, notice that we have used a #cccc99 hex color for the table background. also the (:cellnr:) markup creates a new row, a new cell and closes the row at the end.

You could take this concept a little further: since you might want each page in the group to contain the same table of contents, you can make ONE table like the above and put it in its own page. Then use an include ? on any of your pages and bring in the table. The float (align) property will be honored in each page where it's included. Pretty sweet!

Page last modified on August 14, 2007, at 01:49 PM
All text is available under the terms of the GNU Free Documentation License. (See Copyrights for details.)