Any news re tables and Markdown?
John Gruber
gruber at fedora.net
Fri Mar 11 01:19:45 EST 2005
Michel Fortin <michel.fortin at michelf.com> wrote on 03/08/05 at 8:17pm:
> John may already know how he wants to do it, or he may not know yet --
> I can't tell.
I can't tell either, so I guess that means I don't know yet.
I'm struggling with where to draw the line, because it's obvious to
me that very simple tables should be possible in Markdown. I mean,
it's easy to write a "table" in plain text, but the problem is where
to draw the line that defines "simple tables".
For example, what about alignment? When you do a table like this:
SKU Price
--- ------
a1 $1,050
b1 399
b2 99
It's obvious in plain text that the second column should be
right-aligned. How can that be expressed as Markdown syntax,
however? My guess is that 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.
> The first implementation I made looks like this for a
> mutliple-line-per-row table:
>
> Header 1 Header 2
> =====================
> Cell 1 Two-line
> cell 2.
> ---------------------
> Cell 3 Cell 4
How often are multiple-row cells necessary, however? And how much
work are they to create, even in a real text editor (as opposed to
trying to do them in a browser text area field, which is even
worse)?
I think Markdown's table support will be single-line per-row only.
> Drawbacks:
>
> * Does not work if editing using a proportional font.
That's an issue, and we have to be aware of the fact that many users
write Markdown in textarea fields. But that doesn't mean we need to
cater to them.
> * The table syntax is difficult to tell apart from the SeTex headers
> _in a reliable way_.
Yes. Plus, even if we can parse it accurately in code, there's still
the confusion in the user's mind, because now we've made lines of
dashes into two entirely different magic sequences -- one for h2's,
and one for table headers.
So we might need a different character for this.
SKU Price
--- ------
a1 $1,050
b1 399
b2 99
> To remove the problem of syntax collapsing with SeTex headers, we could
> require a space to separate columns in the header separator at the top
> of the table, like this:
>
> Header 1 Header 2
> ---------- ----------
> Cell 1 Cell 2
> Cell 3 Cell 4
>
> But I have to say I find this less appealing... and doesn't that looks
> more like two SeText headers in a column layout that a table?
I think it looks like a table, but I don't think it solves the
problem, because what if you want a table with only one column?
> Single-line-per-row table:
>
> Header 1 | Header 2
> ------------+----------
> Cell 1 | Cell 2
> Cell 3 | Cell 4
>
[...]
> Drawbacks:
>
> * More characters to write and less clean. (Try writing a somewhat
> big table with this to see how much clutter it is.)
Yeah, it's not terrible, but it does seem cluttered. I've been
thinking about various ways that `|` could be used in tables, though.
> * A table cell can contain a pipe inside a code span. How can we
> separate columns in a multiple-line-per-row table where the code
> span can span on more than one line?
Easy -- by disallowing multi-line table cells. :^)
* * *
For what it's worth, I get a lot of requests for tables. I think
it's probably the most-requested enhancement to the syntax.
And sorry for my relative silence here on the list; I'm just
terrible short of time to spend working on Markdown right now.
-J.G.
More information about the Markdown-Discuss
mailing list