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

(:table (attr...):)

ends any previous table (equivalent to (:tableend:)), and generates a new HTML <table> tag with the attributes given by attr. Valid attributes and values:

  • 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...):)

closes the previous table cell, if any, and generates a new cell with the attributes given by attr. 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).

  • 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..):)

closes the previous table cell, if any, and generates a new cell at the beginning of the next row. In HTML, this creates a “<tr><td attr>” tag, and possibly <table>, </td>, and </tr> tags if they are needed for valid HTML.

  • 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.

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.

Many are likely to ask why we didn’t just use the standard HTML table markup (<table>, <tr>, <td>, <th>) instead of creating a new markup, and allowing nested tables as a result. There are two answers: first, the HTML table markup is very ugly for naive authors (see PmWiki.Audiences and PmWiki.PmWikiPhilosophy #2), and second, it’d be very easy for authors to create tables that are incorrect HTML and that display incorrectly (or not at all) on some browsers. Even seasoned web professionals sometimes get the table markup wrong, so it’s a bit unrealistic to expect the average author to always get it right, or to be able to read arbitrary HTML table markup that someone else has created.

Common comment: Surely, the average or naive author would not be writing HTML directly, but using a tool, such as FrontPage, or even MSWord, to generate the HTML. This would be a lot simpler than learning even the simplest PmWiki markups.

Pm’s Response: And once the HTML has been generated and posted, how is someone else going to edit or modify the table if they don’t have the original FrontPage or MSWord file used to create it? Remember that we’re talking about collaborative authoring. The HTML that those packages generate is among the hardest to read and edit of all!

It’s difficult to write the code needed to make PmWiki understand and fix arbitrary table markup, so PmWiki uses the simplified version above. Still, this version is able to handle most table requirements (with the possible exception of nested tables).

And, this is not to say that nested HTML tables are impossible in PmWiki —they just can’t be easily created by wiki authors using the default wiki markup. A site administrator can of course create header/footer HTML code and other LocalCustomizations that make use of nested tables.

Example 1. A table using advanced 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>

Example 2. A pair of tables using advanced markup.

(:table:)

(:cell:)
%green%[+++Xanadu1+++]
\\
(:include PmWiki/Xanadu#para1#para3:)

(:cell width="10":)

(:cell:)
[[Trainees/HomePage | Attach:home.gif]]
\\\
[[DiscussionForums/HomePage | Attach:talk.gif]]
\\\
[[Main/SiteIndex | Attach:look.gif]]
(:tableend:)

Xanadu1

In Xanadu did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.

Attach:home.gif Δ?


Attach:talk.gif Δ


Attach:look.gif Δ


(:comment attributes of the table as a whole:)
(:table bgcolor=yellow width=600 border=1:)
(:comment Note - width could have been omitted entirely:)

(:comment attributes of the left-most cell:)
(:cell valign="top":)
%green%[+++Xanadu2+++]
\\
(:include PmWiki/Xanadu#para3#para4:)

(:comment attributes of the center cell, functions as a spacer column:)
(:cell bgcolor=blue color=red valign="middle" width="10":)
(:comment Note - cellpadding or cellspacing might obviate the need for this
column:)
test

(:comment attributes of the right-most cell:)
(:cell valign="top":)
(:comment Note - consists of images stacked above one another:)
[[Trainees/HomePage | Attach:home.gif]]
\\\
[[DiscussionForums/HomePage | Attach:talk.gif]]

(:cellnr:)
what if I only specify one cell on the second row?
(:cellnr:)
(:include PmWiki/Xanadu#para4#para5:)
(:cell:)

(:cell valign=top:)
\\
[[Main/SiteIndex | Attach:look.gif]]

(:tableend:)

Xanadu2

But oh! that deep romantic chasm which slanted
Down the green hill athwart a cedarn cover!
A savage place! as holy and enchanted
As e’er beneath a waning moon was haunted
By woman wailing for her demon-lover!
And from this chasm, with ceaseless turmoil seething,
As if this earth in fast thick pants were breathing,
A mighty fountain momently was forced:
Amid whose swift half-intermitted burst
Huge fragments vaulted like rebounding hail,
Or chaffy grain beneath the thresher’s flail:
And ‘mid these dancing rocks at once and ever
It flung up momently the sacred river.
Five miles meandering with a mazy motion
Through wood and dale the sacred river ran,
Then reached the caverns measureless to man,
And sank in tumult to a lifeless ocean:
And ‘mid this tumult Kubla heard from far
Ancestral voices prophesying war!

test

Attach:home.gif Δ?


Attach:talk.gif Δ

what if I only specify one cell on the second row?

The shadow of the dome of pleasure
Floated midway on the waves;
Where was heard the mingled measure
From the fountain and the caves.
It was a miracle of rare device,
A sunny pleasure-dome with caves of ice!


Attach:look.gif Δ

« | DocumentationIndex | »

Last edited by Lipek. Based on work by JeffBarke and TeganDowling.  Page last modified on May 16, 2005

Legal Information |  Designed and built by Emergency Digital. | Hosted by Steadfast Networks