Any news re tables and Markdown?
Michel Fortin
michel.fortin at michelf.com
Sat Mar 12 08:39:37 EST 2005
Le 11 mars 2005, à 1:19, John Gruber a écrit :
> For example, what about alignment? When you do a table like this:
>
> SKU Price
> --- ------
> a1 $1,050
> b1 399
> b2 99
>
> [...] Markdown could look at the offsets of the items in each row, and
> if the end offset for each item in a row is at the same column (i.e.
> character position in the line), then it's right-aligned. But this
> pretty much means you have to be using a monospaced font to get
> columns to right-align.
As much as I like the idea of catching alignment by looking at the
content, I think this is completely unreliable because it requires cell
content to be of different length. To take your example, what can you
do if the prices you have looks like below?
SKU Price
--- ------
a1 $1,050
b1 39,902
b2 99,212
A way to remove the ambiguity is to require the separator line to be
longer than the header. If it is longer on the right, it's
left-aligned; if it is longer on the left, it's right-aligned; if it is
longer than the header on both side then it's center-aligned:
Left Right Center Default
----- ------- ---------- -------
0110 011010 10010100 01001
1101 110100 01001011 00111
If the header separator line is the same length than the header, there
is no align attribute and the browser will use the style sheet's
default.
(Note: I say the header here, where I could say that the separator line
must be longer that the entire content. This is because the content can
be long, and maintaining it's alignment can be error-prone (or you
could just be lazy). By keeping alignement behaviour linked only to the
header, I believe that it will cause less trouble, and it's easier to
change too.)
* * *
If we want to add support for proportional font, we need a column
separator. Pipes could be allowed (but not required) like that:
Left | Right | Center | Default
----- | ------- | ---------- | -------
0110 | 011010 | 10010100 | 01001
1101 | 110100 | 01001011 | 00111
Pipes are optional on the left and right side of the table:
| Left | Right | Center | Default |
| ----- | ------- | ---------- | ------- |
| 0110 | 011010 | 10010100 | 01001 |
| 1101 | 110100 | 01001011 | 00111 |
And now there is now an unambiguous way to create a single-column table:
| SKU
| ---
| a1
| b1
(Note: there is still something that doesn't work here: alignement.
With a proportional font, you can't rely on the number of dash to check
for text alignment inside the column like I proposed above.)
Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/
More information about the Markdown-Discuss
mailing list