Thoughts on character to indicate table headers?

18 views
Skip to first unread message

mdepot

unread,
Nov 4, 2009, 3:08:44 PM11/4/09
to asciidoc, mde...@comcast.net
It occurred to me it might be nice to support an alternate character
for flagging table headers. This might give a little extra
flexibility in certain situations, like vertical headers for example.
Please look at Dokuwiki's use of the caret character in their table
syntax as an example :
http://www.dokuwiki.org/syntax#tables
I'd be interested to hear people's thoughts on this syntax, and if
using an alternate character to indicate a table header might be a
good fit for AsciiDoc...

Stuart Rackham

unread,
Nov 4, 2009, 7:30:11 PM11/4/09
to asci...@googlegroups.com
My 2 cents worth:

I decided against separate header and footer syntax because I wanted to
keep the cell/row data format homogeneous and independent of the table
format. This allows you to include external files (e.g. CSV files) that
already have header rows. The implementation is also simplified.

This is from the longer discussion about New Tables when the current syntax was
introduced:

http://groups.google.com/group/asciidoc/browse_frm/thread/2b9bbc60f947cba0/1f3eef71c56b5400?lnk=gst&q=new+tables#1f3eef71c56b5400


Cheers, Stuart

>
> --
>
> You received this message because you are subscribed to the Google Groups "asciidoc" group.
> To post to this group, send email to asci...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/asciidoc?hl=en.
>
>
>

mdepot

unread,
Nov 4, 2009, 8:58:37 PM11/4/09
to asciidoc
> I decided against separate header and footer syntax because I wanted to
> keep the cell/row data format homogeneous and independent of the table
> format.

I was interested in a way to create tables with vertical headers, or
even with both horizontal and vertical as would be typical for such
things as cross tabs, pivot tables, contingency tables, and matrices.
These are all common and popular table layouts so it would be useful
to be able to represent them.

Rather than the first idea of using a character to flag a header cell,
here's an alternative that might be more in line with your design
goals. How about adding a "headers" option that could be included in
the bracketed definition. Ex:

.Sales by Region
[headers="1r,1c"]
|==================================
| |West |Central |East | Total
|Q1 |270 |292 |342 | 904
|Q2 |322 |276 |383 | 981
|Q3 |298 |252 |274 | 824
|Q4 |344 |247 |402 | 993
|Total |1234 |1067 |1401 |
|==================================

In the example above (those are ones, not ells), both the first row
(1r) and the first column (1c) would be headers. This syntax would be
backward compatible as well as allow for a good deal of expansion.
For instance if you wanted the second column, you could use "2c".
Negative indexes could be used to count from the other side of the
table, so "-1r" would be equivalent to a footer, and -1c would be the
rightmost column. So perhaps [headers="1r,1c,-1r,-1c"] might be
desired for the table above.

This could further be expanded with cell level syntax, for example the
empty cell in the upper left corner could be specified with "1.1", and
the blank cell in the bottom right would be "-1.-1". Finally negation
could be added with a ! to invert the current setting. So above if
you wanted header and footer rows, as well as the left and right total
columns, but not the two empty cells, you could use [headers="1r,
1c,-1r,-1c,!1.1,!-1.-1"]

Ok, maybe I'm getting carried away. Perhaps just file this away for
future thought...

Cheers :-)

Stuart Rackham

unread,
Nov 4, 2009, 11:33:03 PM11/4/09
to asci...@googlegroups.com
This does what you're after:

.Sales by Region
[cols="s,4*",options="header"]
|==================================
| |West |Central |East | Total
|Q1 |270 |292 |342 | 904
|Q2 |322 |276 |383 | 981
|Q3 |298 |252 |274 | 824
|Q4 |344 |247 |402 | 993
|Total |1234 |1067 |1401 |
|==================================

The first column is strong (bold) like the header. It falls down a little with
xhtml11 outputs because the default table header style is not exactly the same
as the strong cell style -- perhaps an explicit 'header' style that formats the
designated column using the same style as the horizontal header e.g.

[cols="h,4*",options="header"]


Cheers, Stuart


>
> Cheers :-)

srackham

unread,
Dec 4, 2009, 7:50:44 PM12/4/09
to asciidoc
I've added a 'header' table style. See:
http://hg.sharesource.org/asciidoc/rev/bd6bae9f0596
Reply all
Reply to author
Forward
0 new messages