Proposed table syntax

Joshua Cook ijoshua at
Fri Oct 22 11:03:14 EDT 2004

I've been following this thread intently, and I've seen some good
ideas, but nothing so far has seemed completely acceptable.  So I
thought about it and came up with my own ideas.

Considering the way tables are marked up in HTML, a few rules come to mind:

1.  There must be delimiters for the table cells, rows and the table itself.
2.  There must be a way to differentiate headers and normal cells.
3.  There *will* be a need for block-level formatting with table
cells.  This includes nested tables.

So here are my ideas:

1.  Table rows are delimited by a vertical pipe (``|'') at the
beginning and a line break at the end.
2.  Any number (greater than zero) of consecutive table rows make up a table.
3.  Vertical pipes within a row delimit cells.  Whitespace is not
acceptable as a cell delimiter, because it will be used for visual
4.  Leading and trailing whitespace within a cell is ignored.  Cells
containing only whitespace are considered empty.
5.  Cells may span multiple lines, and therefore contain block-level
formatting syntax, by enclosing the cell contents in curly braces
(``{'' and ``}'').
6.  Header cells are identified by an ``='' after the vertical pipe.

An example:

    |=     Company         |=     Description            |=     URI
    | Apple Computer, Inc. |{
    The maker of:
    * Macintosh
    * iPod
    * QuickTime
    * FireWire
    | Microsoft            | No need for a description.  |

Row- and column-spanning are a different problem.  One idea I had is
to use a special syntax for defining the attributes of HTML elements. 
This could work for rowspan and colspan for table cells as well as
class and id for other elements.  Here is a contrived example:

    |@[rowspan="2"]    |@[colspan="2"]=                Gender             |
    |=                                    Male             |= Female  
   |= Average
    |=                      Avg. Height | 1.9              |  1.7         |  1.8
    |=                      Avg. Weight | 0.003            |  0.002   
   |  0.0025

Which would be formatted like:

    <tr><td rowspan="2"></td><th colspan="2">Gender</th><td></td></tr>
    <tr><th>Avg. Height</th><td>1.9</td><td>1.7</td><td>1.8</td></tr>
    <tr><th>Avg. Weight</th><td>0.003</td><td>0.002</td><td>0.0025</td></tr>

Extending this example to other elements:

    #@[id="title"] A Book Title
    ## Table of Contents
    1.  [Chapter 1](#ch1)
    2.  [Chapter 2](#ch2)
    3.  [Chapter 3](#ch3)
        1.  [Section 1](#ch3-1)
        2.  [Section 2](#ch3-2)
    4.  [Chapter 4](#ch4)
    #@[id="ch1"] Chapter 1
    #@[id="ch2"] Chapter 2
    #@[id="ch3"] Chapter 3
    ##@[id="ch3-1"] Section 1
    ##@[id="ch3-2"] Section 2
    #@[id="ch4"] Chapter 4
would give:

    <h1 id="title">A Book Title</h1>
    <h2>Table of Contents</h2>
    <ol class="toc">
    <li><a href="#ch1">Chapter 1</a></li>
    <li><a href="#ch2">Chapter 2</a></li>
    <li><a href="#ch3">Chapter 3</a>
    <li><a href="#ch3-1">Section 1</a></li>
    <li><a href="#ch3-2">Section 2</a></li>
    <li><a href="#ch4">Chapter 4</a></li>
    <h1 id="ch1">Chapter 1</h1>
    <h1 id="ch2">Chapter 2</h1>
    <h1 id="ch3">Chapter 3</h1>
    <h2 id="ch3-1">Section 1</h2>
    <h2 id="ch3-2">Section 2</h2>
    <h1 id="ch4">Chapter 4</h1>

** By the way: ** the Markdown dingus still formats this nested list

More information about the Markdown-discuss mailing list