1 [[!template id=gitbranch branch=jon/table_headerblock author="[[Jon]]"]]
2 It would be great if it were possible to support multi-row table headers in the [[plugins/table]] plugin, so you could do e.g.
6 | Windows | Mac | Linux
13 [[!tag wishlist patch]]
15 > This seems like weird overloading of the header parameter - it's
16 > table data, except when it isn't.
18 > > My first cut (now rebased out of existence I think) introduced a
19 > > new "headerblock" parameter, but trying to clearly document the
20 > > interaction of data/headerblock/header parameters was too awkward. -- [[Jon]]
23 > something like this would be easier to use in practice?
24 > (and also more featureful :-) )
26 > \[[!table header="2 rows 1 column" data="""
28 > | Windows | Mac | Linux
29 > ikiwiki | no | yes | yes
30 > Starcraft | yes | yes | via Wine
33 > > Thanks for your prompt feedback!
35 > > This would probably be good, yes, and having mixed row/column headers is
36 > > definitely a nice-to-have. I don't relish the prospect of writing the parser
37 > > but I see you've made a stab already...
39 > > One thing you'd lose, but it's debatable whether this is valuable, would be
40 > > to have the header defined in the directive, and the remaining table data
41 > > declared in an external CSV. -- [[Jon]]
43 > intended to be rendered like
46 > <tr><th>Name</th><th colspan=2>Platform</th>
47 > <tr><th></th><th>Windows</th><th>Mac</th><th>Linux</th></tr>
48 > <tr><th>ikiwiki</th><td>no</td><td>yes</td><td>yes</td></tr>
49 > <tr><th>Starcraft</th><td>yes</td><td>yes</td><td>via Wine</td></tr>
52 > (Deliberately switching to plain-text to make it more obvious
53 > what's a `<th>` and what's `<td>`.)
55 > Vague pseudocode for parsing `headers`
56 > (possibly even valid Perl, I'm not sure):
58 > my ($header_rows, $header_cols);
59 > while ($header =~ s/(\d*)\W*(\w+)//) {
62 > if ($what =~ m/rows?/) {
65 > elif ($what =~ m/col(?:umn)?s?/) {
70 > and it would even be fairly easy to extend to support
71 > `(first|last|)\W*(\d*)\W*(\w+)` later, e.g.
72 > `header="1 row, first 2 cols, last column"`.
76 > > To be clear I think your suggestion is a good one, but my hack has
77 > > addressed my immediate need so it's the one I'm deploying at $ork for the
78 > > time being. I'm unlikely to have time to implement this solution in the
79 > > near future. -- [[Jon]]