Tables

Michel Fortin michel.fortin at michelf.com
Tue Nov 15 17:35:19 EST 2005


Le 2005-11-15 à 14:15, Fletcher T. Penney a écrit :


> I second this - the first option below would be much more difficult

> to implement and change than the second option (I went with the

> second option for MultiMarkdown)


So, let's summarize the `colspan` ideas.

First option.

|| || Imported || Domestic ||
|| || Beans | Peas || Carrots | Tomatoes ||
|| || ----- | ----- || ------- | -------- ||
|| Wholesale || $1.00 | $1.25 || $1.20 | $1.20 ||
|| Retail || $2.00 | $3.00 || $1.80 | $1.80 ||

First option, second version.

| | Imported | Domestic |
| | Beans || Peas | Carrots || Tomatoes |
| | ----- || ----- | ------- || -------- |
| Wholesale | $1.00 || $1.25 | $1.20 || $1.20 |
| Retail | $2.00 || $3.00 | $1.80 || $1.80 |

The interesting thing about this first table syntax is that you don't
really care about the number of column a cell span to when writing
the table, you care about column *groups*.

I don't think it would be that much difficult to implement this first
option -- I mean the two versions at the same time. I say that
because I already know exactly how it would work. Even this minimal
thing could work:

| | Imported || Domestic
| | Beans | Peas || Carrots | Tomatoes
| | ----- | ----- || ------- | --------
| Wholesale | $1.00 | $1.25 || $1.20 | $1.20
| Retail | $2.00 | $3.00 || $1.80 | $1.80

All that is needed is that the vertical line that ends a cell
spanning on multiple columns be made of a different number of pipe
than for its sub-columns.

(Note that I didn't remove the leading pipe in this *minimal*
version. This is because the first cell is empty and a line beginning
with four space would be seen as a code block. But with some content
in the first cell, the first pipe could be removed.)

- - -

Second option, as implemented by MultiMarkdown.

| | Imported || Domestic ||
| | Beans | Peas | Carrots | Tomatoes |
| | ----- | ----- | ------- | -------- |
| Wholesale | $1.00 | $1.25 | $1.20 | $1.20 |
| Retail | $2.00 | $3.00 | $1.80 | $1.80 |

This second option is pretty easy to implement. I have to says that
while it works, I don't think it looks so good, especially if you
have more than two sub-columns in a group.

While in my first option you have to take care about the number of
pipes when inserting new columns, in this second option you have to
re-count the number of cells in the group and adjust the number of pipe.

Which one is better? I'm not sure. It probably depends on your
editing style. But I prefer the first option.


Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/




More information about the Markdown-Discuss mailing list