Tables

John Gruber gruber at fedora.net
Mon Nov 14 17:20:20 EST 2005


So I needed a table for my PowerBook review last week, and the laziest way to write it seemed to be to use PHP Markdown Extra (PME). I wrote it like this:

|Display | Width | Height | PPI |
|---------------------------|------:|-------:|----:|
|12-inch PowerBook/iBook | 1024 | 768 | 107 |
|14-inch iBook | 1024 | 768 | 91 |
|15-inch PowerBook G4 (new) | 1440 | 960 | 115 |
|15-inch PowerBook G4 (old) | 1280 | 854 | 103 |
|17-inch PowerBook G4 (new) | 1680 | 1050 | 117 |
|17-inch PowerBook G4 (old) | 1440 | 960 | 102 |
|20-inch Cinema Display | 1680 | 1050 | 99 |
|23-inch Cinema Display | 1920 | 1200 | 98 |
|30-inch Cinema Display* | 2560 | 1600 | 102 |

My biggest gripe about PME's table syntax is the use of colons for
marking column alignment. It seems rather against Markdown's goals
of not having syntax elements that look like markup rules, but
rather that everything should just look like what it is. Just
ever-so-slightly crufty, to my eyes.

So why not get rid of the colons, and do column alignment based on
the number of spaces between the items in the column and the pipes?

So instead of:

| Height |
|-------:|
| 854 |
| 1050 |
| 960 |

You'd write this:

| Height |
|--------|
| 854 |
| 1050 |
| 960 |

and Markdown would "know" that the column should be right-aligned
because every item is one space from the right side. Whereas if it
were:

| Height |
|--------|
| 854 |
| 1050 |
| 960 |

It'd be left-aligned.

Seems like this should work even for people who are editing in
variable-width fonts.

The only hiccup would be centering. Not sure how this rule could
work for that. So maybe we'd keep the colons as an option for left-
and right- alignment, and as the only way to do column centering?

* * *

Another question:

Why not just require that every line of a table must start with a
pipe (`|`)? Michel's PME implementation is existence proof that it's
possible to write code to parse out tables even if they don't start
with a pipe, but it seems like maybe it would make the rules easier
to remember and simpler, and it would make it easier to see where
tables start and end. Just throwing ideas out there.

-J.G.




More information about the Markdown-Discuss mailing list