version=pmwiki-2.1.14 ordered=1 urlencoded=1
agent=Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.0.6) Gecko/20060728 SUSE/1.5.0.6-1.3 Firefox/1.5.0.6
author=Pm
csum=minor edits
host=24.1.26.255
name=PmWiki.TableDirectives
rev=39
targets=PmWiki.Tables,PmWiki.TableDirectives,PmWiki.Audiences,PmWiki.PmWikiPhilosophy,PmWiki.LocalCustomizations,PmWiki.TextFormattingRules,PmWiki.IncludeOtherPages,PmWiki.DocumentationIndex
text=%25audience%25 authors (intermediate)%0a%0a(:title Table Directives:)%0aThere are four directives for table processing.  All must be at the beginning of a line to have any effect.%0a%0a!!![@(:table (attr...):)@]%0aGenerates a new HTML %3ctable> tag with the attributes provided in ''attr...''.%0aCloses the previous table, if any.%0aValid attributes and values are:%0a* border ''(a positive integer)''%0a* bordercolor ''(a color name or hex number; doesn't display in all browsers)''%0a* cellspacing ''(a positive integer indicating the space between cells)''%0a* cellpadding ''(a positive integer indicating the interior border of a cell)''%0a* width ''(a positive integer or percent)''%0a* bgcolor ''(a color name or hex number)''%0a* align ''(left, center or right)''%0a* summary ''(does not display; used primarily to help visually disabled people navigate)''%0a%0a!!![@(:cell (attr...):)@]%0aGenerates a new cell with the attributes given by ''attr...''.  %0aCloses the previous table cell, if any.%0aIn HTML, this creates a new "%3ctd attr>" tag (and possibly %3ctable>, %3ctr>, and %3c/td> tags if they are needed to produce a valid HTML table). %0a%0a->%25note%25 '''Note:''' Placing a space after the cell markup "(:cell:) " causes subsequent text on that line to be treated as preformatted text.%0a%0aValid attributes and values are:%0a* align ''(left, center or right)''%0a* valign ''(top, middle or bottom)''%0a* colspan ''(a positive integer)''%0a* rowspan ''(a positive integer)''%0a* bgcolor ''(a color name or hex number)''%0a* width ''(a positive integer or percent)''%0a%0a!!![@(:cellnr (attr..):)@]%0aGenerates a new cell at the beginning of the next row.%0aCloses the previous table cell, if any.%0aIn HTML, this creates a "%3ctr>%3ctd attr>" tag, and possibly %3ctable>, %3c/td>, and %3c/tr> tags if they are needed for valid HTML.%0aValid attributes and values are:%0a* align ''(left, center or right)''%0a* valign ''(top, middle or bottom)''%0a* colspan ''(a positive integer)''%0a* rowspan ''(a positive integer)''%0a* bgcolor ''(a color name or hex number)''%0a* width ''(a positive integer or percent)''%0a%0a!!![@(:tableend:)@]%0aCloses the previous table cell and closes off any table.  Generates %3c/td>, %3c/tr>, and %3c/table> tags as needed.%0a%0a!! Notes%0a%0aFor the table, cell, and cellnr tags the author can specify any attributes that would be valid in the HTML %3ctable> or %3ctd> 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.%0a%0aMany are likely to ask why we didn't just use the standard HTML table markup (%3ctable>, %3ctr>, %3ctd>, %3cth>) 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 [[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.%0a%0a-> %25color=green%25 ''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.%0a%0a-> %25color=green%25 ''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!%0a%0aIt'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).%0a%0aAnd, 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 [[local customizations]] that make use of nested tables.%0a%0a!!!Example 1.  A table using table directive markup.%0a%0a(:markup:) [=%0a(:table border=1 cellpadding=5 cellspacing=0:)%0a(:cell:) a1%0a(:cell:) b1%0a(:cell:) c1%0a(:cell:) d1%0a(:cellnr:) a2%0a(:cell:) b2%0a(:cell:) c2%0a(:cell:) d2%0a(:tableend:)%0a=]%0a%0a%0aIn HTML, this is the same as%0a%0a-> [@%0a%3ctable border='1' cellpadding='5' cellspacing='0'>%0a  %3ctr>%0a    %3ctd>a1%3c/td>%0a    %3ctd>b1%3c/td>%0a    %3ctd>c1%3c/td>%0a    %3ctd>d1%3c/td>%0a  %3c/tr>%0a  %3ctr>%0a    %3ctd>a2%3c/td>%0a    %3ctd>b2%3c/td>%0a    %3ctd>c2%3c/td>%0a    %3ctd>d2%3c/td>%0a  %3c/tr>%0a%3c/table>%0a@]%0a%0a%0a-----%0a!!!Floating Table with bulleted navigation list%0a%0a(:table border=1 width=30%25 align=right bgcolor=#cccccc cellspacing=0 :)%0a(:cellnr:)%0a'''Navigation Links'''%0a(:cellnr:)%0a*[[Text formatting rules]]%0a*[[Tables]]%0a*[[Table directives]]%0a(:tableend:)%0a%0aWhat 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.%0a%0a(:markup:)%0a(:table border=1 width=30%25 align=right bgcolor=#cccc99 cellspacing=0 :)%0a(:cellnr:)%0a'''Navigation Links'''%0a(:cellnr:)%0a*[[Tables]]%0a*[[Table directives]]%0a(:tableend:)%0a(:markupend:)%0a%0a(:markup:)%0a(:table border=1 width=30%25 align=right bgcolor=#cccc99 cellspacing=0 :)%0a(:cellnr colspan=2 align=center:)%0a'''Navigation Links'''%0a(:cellnr align=center:)%0a[[Tables]]%0a(:cell align=center:)%0a[[Table directives]]%0a(:tableend:)%0a(:markupend:)%0a%0aLooking 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.%0a%0aYou 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 (other pages)]] 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!%0a%0a%0a%25trail%25 %3c%3c|[[Documentation Index]]|>>%0a%0a>>faq%3c%3c [[#faq]]%0a%0aQ: Can I define table headers using the table directive markup?%0aA: No, but you can with [[Cookbook:AdvancedTableDirectives]]. See [[PITS:00535#pmanswer|Pm's reply]] to pending [[PITS:00535]]%0a
time=1156527396
title=Table Directives
