Any news re tables and Markdown?

Michel Fortin michel.fortin at michelf.com
Tue Mar 8 20:17:58 EST 2005


I currently have two table syntaxes with the implementation ready in 
PHP. Ready means that they work but I'm waiting to see what the syntax 
will actually be like before publishing any code.

I must say I'm also eager to see what John will decide Markdown about 
how tables will looks like. What I think he will do is to code a 
prototype and make experiments with it, until he find a good compromise 
between the different goals of Markdown. At least, that's the way I 
would do it.

With my own two PHP prototypes, I have to say I'm equally divided 
between the two syntaxes. I can't decide which one is better. Each of 
them has some advantages and drawbacks. While there is a syntax I like 
much better than the other, it has some important drawbacks the other 
does not have. Maybe both syntax could be supported, but I'm not sure 
this wouldn't turn into a mess.

John may already know how he wants to do it, or he may not know yet -- 
I can't tell. But my point here is that it involve some thoughts to 
carefully choose the syntax, and it probably require experiments using 
it for some time too (like I'm doing currently with my own). So I'm 
ready to wait.

If you are interested, here is a small comparaison of my two syntax for 
table in plain text. (If you're not interested, there is nothing else 
for you below.)

* * *

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

Single-line-per-row table:

	Header 1   Header 2
	---------------------
	Cell 1     Cell 2
	Cell 3     Cell 4

It use no column separator at all, except for the header row. Each 
header are separated by two spaces or more. Then, to separate columns 
from each other on the following rows, my table parser divide each cell 
using the length of the header for that column. For example, this:

	Header 1     Header 2
	--------------------------
	abcdefghijklmnopqrstuvwxyz

would create the following table:

	<table>
	<tr><th>Header 1</th><th>Header 2</th></tr>
	<tr><td>tdabcdefghijklm</td><td>nopqrstuvwxyz</td></tr>
	</table>

As you see, `abcdefghijklm` was separated from `nopqrstuvwxyz` using 
the virtual line created by the beginning of Header 2 just above.

Advantages:

*	You can't do cleaner than that.
*	I like it! :-)

Drawbacks:

*	Does not work if editing using a proportional font.
*	The table syntax is difficult to tell apart from the SeTex headers
	_in a reliable way_.

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?

* * *

The second one use `|` as a column separator. A mutliple-line-per-row 
table looks like this:

	Header 1    |  Header 2
	============+============
	Cell 1      |  Two-line
	            |  cell 2.
	------------+------------
	Cell 3      |  Cell 4

Single-line-per-row table:

	Header 1    |  Header 2
	------------+----------
	Cell 1      |  Cell 2
	Cell 3      |  Cell 4

Note that the `+` is purely cosmetic and completely optional.

Advantages:

*	Works well even with proportional fonts, since you don't have to
	count the number of space you write.
*	The last point means that it will work better that the first with
	most weblog software (where the editing font in the admin interface
	is proportional).

Drawbacks:

*	More characters to write and less clean. (Try writing a somewhat
	big table with this to see how much clutter it is.)
*	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?


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



More information about the Markdown-Discuss mailing list