]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/support_multi-row_table_headers.mdwn
Merge branch 'ready/trail-sort'
[ikiwiki.git] / doc / todo / support_multi-row_table_headers.mdwn
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.
3
4         \[[!table header="""
5         Name | Platform ||
6         | Windows | Mac | Linux
7         """ data="""
8         ikiwiki | ‧ | ✓ | ✓
9         """]]
10
11 -- [[Jon]]
12
13 [[!tag wishlist patch]]
14
15 > This seems like weird overloading of the header parameter - it's
16 > table data, except when it isn't.
17
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]]
21
22 > Perhaps
23 > something like this would be easier to use in practice?
24 > (and also more featureful :-) )
25 >
26 >     \[[!table header="2 rows 1 column" data="""
27 >     Name | Platform ||
28 >     | Windows | Mac | Linux
29 >     ikiwiki | no | yes | yes
30 >     Starcraft | yes | yes | via Wine
31 >     """]]
32
33 > > Thanks for your prompt feedback!
34 > > 
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...
38 > > 
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]]
42
43 > intended to be rendered like
44 >
45 > <table>
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>
50 > </table>
51 >
52 > (Deliberately switching to plain-text to make it more obvious
53 > what's a `<th>` and what's `<td>`.)
54 >
55 > Vague pseudocode for parsing `headers`
56 > (possibly even valid Perl, I'm not sure):
57 >
58 >     my ($header_rows, $header_cols);
59 >     while ($header =~ s/(\d*)\W*(\w+)//) {
60 >         my $n = ($1 or 0);
61 >         my $what = $2;
62 >         if ($what =~ m/rows?/) {
63 >             $header_rows = $n;
64 >         }
65 >         elif ($what =~ m/col(?:umn)?s?/) {
66 >             $header_cols = $n;
67 >         }
68 >     }
69 >
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"`.
73 >
74 > --[[smcv]]
75
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]]