BoundedTablePlugin
Renders tables from a bounded specification starting with %BOUNDEDTABLE{}% and finishing with %ENDBOUNDEDTABLE%. I got tired of the lack of css support in the table statement and with the inconvenience of having to escape all the lines in a row.
BoundedTablePlugin addresses both these issues.
BoundedTablePlugin does all the rendering using styles and uses a non TWiki type syntax for the table. The syntax is based on the syntax proposed in
Wikipedia
.
Syntax Rules
- Bounded tables start with a %BOUNDEDTABLE{...}% statement
- and fninish with a %ENDBOUNDEDTABLE% statement
- bounded tables can be nested
- bounded tables use |- (pipe, minus) in column one as the row separator
- bounded tables identify a cell as bounded by two pipes, Like TWiki tables
- since rows are separately identified, cells can continue over multiple lines. without special syntax
Table Attributes
Attributes are defined in line before the table using %BOUNDEDTABLE{...}%:
| Argument |
Comment |
Example |
| tablewidth |
The width of the table in px, % or other valid value. |
tablewidth="auto" |
| tableclass |
The class associated with the <TABLE tag. |
tableclass="boundedtable" |
| columnwidths |
The width of each column in px, % or other value value. |
columnwidths="60%, 30%, 10%" |
| headerrows |
The number of rows in the header. |
headerrows="1" |
Examples
Define the following styles:
/* additions to test the BOUNDEDTABLE plugin */
table.boundedtable {border: 5px solid #ff0000;}
table.boundedtable tr th {text-align:center;font-weight: bold; padding: 2px; color: #00ff00; background: #0000ff}
table.boundedtable tr.oddrow {background: #00f000}
table.boundedtable tr.evenrow {background: #0000f0}
table.plainboundedtable {border-collapse:collapse;border: 1px solid #003f9f;border-spacing: 0px}
table.plainboundedtable tr th {text-align:left;font-weight: bold; padding: 2px; color: #c2d4ef; background: #003f9f}
table.plainboundedtable tr {padding: 2px; background: #c2d4ef}
table.twikiboundedtable {border: 1px solid #003f9f;border-spacing: 0px}
table.twikiboundedtable tr th { background: #99CCCC}
table.twikiboundedtable tr.oddrow {background: #FFFFFF}
table.twikiboundedtable tr.evenrow {background: #FFFFCC}
The following code presents the table below.
%BOUNDEDTABLE{tableclass="boundedtable" tablewidth="60%" columnwidths="60%, 30%, 10%" headerrows="1"}%
|cell 1 1| cell 1 2| cell 1 3|
|-
| cell 2 1|cell 2 2|
%BOUNDEDTABLE{tableclass="boundedtable" columnwidths="80%, 20%"}%
|T1|T2|
|-
||row 2 2|
%ENDBOUNDEDTABLE%
|
|-
| cell 3 1| cell 3 2| cell 3 3|
|-
| cell 4 1| cell 4 2| cell 4 3|
|-
|
%BOUNDEDTABLE{tableclass="boundedtable" tablewidth="100%" columnwidths="40%, 60%"}%
|T1|T2|
|-
||row 2 2|
%ENDBOUNDEDTABLE%
|| cell 5 3|
|-
| cell 6 1| cell 6 2| cell 6 3|
%ENDBOUNDEDTABLE%
%BOUNDEDTABLE{tableclass="boundedtable" tablewidth="60%" columnwidths="60%, 30%, 10%" headerrows="1"}%
| cell 1 1 |
cell 1 2 |
cell 1 3 |
|-
%BOUNDEDTABLE{tableclass="boundedtable" columnwidths="80%, 20%"}%
|-
%ENDBOUNDEDTABLE%
|
|-
| cell 3 1 |
cell 3 2 |
cell 3 3 |
|-
| cell 4 1 |
cell 4 2 |
cell 4 3 |
|-
|
%BOUNDEDTABLE{tableclass="boundedtable" tablewidth="100%" columnwidths="40%, 60%"}%
|-
%ENDBOUNDEDTABLE%
|-
| cell 6 1 |
cell 6 2 |
cell 6 3 |
%ENDBOUNDEDTABLE%
When you change the tableclass to
plainboundedtable
%BOUNDEDTABLE{tableclass="plainboundedtable" tablewidth="60%" columnwidths="60%, 30%, 10%" headerrows="1"}%
the presentation becomes:
%BOUNDEDTABLE{tableclass="plainboundedtable" tablewidth="60%" columnwidths="60%, 30%, 10%" headerrows="1"}%
| cell 1 1 |
cell 1 2 |
cell 1 3 |
|-
%BOUNDEDTABLE{tableclass="boundedtable" columnwidths="80%, 20%"}%
|-
%ENDBOUNDEDTABLE%
|
|-
| cell 3 1 |
cell 3 2 |
cell 3 3 |
|-
| cell 4 1 |
cell 4 2 |
cell 4 3 |
|-
|
%BOUNDEDTABLE{tableclass="boundedtable" tablewidth="100%" columnwidths="40%, 60%"}%
|-
%ENDBOUNDEDTABLE%
|-
| cell 6 1 |
cell 6 2 |
cell 6 3 |
%ENDBOUNDEDTABLE%
And when you change the tableclass to
twikiboundedtable
%BOUNDEDTABLE{tableclass="twikiboundedtable" tablewidth="60%" columnwidths="60%, 30%, 10%" headerrows="1"}%
the presentation becomes:
%BOUNDEDTABLE{tableclass="twikiboundedtable" tablewidth="60%" columnwidths="60%, 30%, 10%" headerrows="1"}%
| cell 1 1 |
cell 1 2 |
cell 1 3 |
|-
%BOUNDEDTABLE{tableclass="boundedtable" columnwidths="80%, 20%"}%
|-
%ENDBOUNDEDTABLE%
|
|-
| cell 3 1 |
cell 3 2 |
cell 3 3 |
|-
| cell 4 1 |
cell 4 2 |
cell 4 3 |
|-
|
%BOUNDEDTABLE{tableclass="boundedtable" tablewidth="100%" columnwidths="40%, 60%"}%
|-
%ENDBOUNDEDTABLE%
|-
| cell 6 1 |
cell 6 2 |
cell 6 3 |
%ENDBOUNDEDTABLE%
Plugin Settings
Plugin settings are stored as preferences variables. To reference a plugin setting write
%<plugin>_<setting>%, i.e.
%INTERWIKIPLUGIN_SHORTDESCRIPTION%
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Extended table syntax with support for nested tables and CSS
- Debug plugin: (See output in
data/debug.txt)
- Default boundedtable attributes
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
- Download the ZIP file from the Plugin web (see below)
- Unzip
BoundedTablePlugin.zip in your twiki installation directory. Content: | File: | Description: |
data/TWiki/BoundedTablePlugin.txt | Plugin topic |
data/TWiki/BoundedTablePlugin.txt,v | Plugin topic repository |
lib/TWiki/Plugins/BoundedTablePlugin.pm | Plugin Perl module |
- Test if the installation was successful:
- the samples at the bottom of this page should appear like the pictures above
Plugin Info
Related Topics: TWikiPreferences,
TWikiPlugins
--
TWiki:Main.BramVanOosterhout
- 05 Nov 2005