You are not logged in Log in Join
You are here: Home » Members » jim » StructuredTextWiki » StructuredTextTables

Log in
Name

Password

 
 

History for StructuredTextTables

??changed:
-
The current rule for tabs

  A paragraph that has blocks of text enclosed in '||' is treated as a
  table. The text blocks correspond to table cells and table rows are
  denoted by newlines. By default the cells are center aligned. A cell
  can span more than one column by preceding a block of text with an
  equivalent number of cell separators '||'. Newlines and '|' cannot
  be a part of the cell text. For example::

    |||| **Ingredients**    ||
      || *Name* || *Amount* ||
      ||Spam    || 10       ||
      ||Eggs    || 3        ||

  This is interpreted as::

    <TABLE BORDER=1 CELLPADDING=2>
     <TR>
      <TD ALIGN=CENTER COLSPAN=2> <strong>Ingredients</strong> </TD>
     </TR>
     <TR>
      <TD ALIGN=CENTER COLSPAN=1> <em>Name</em> </TD>
      <TD ALIGN=CENTER COLSPAN=1> <em>Amount</em> </TD>
     </TR>
     <TR>
      <TD ALIGN=CENTER COLSPAN=1>Spam</TD>
      <TD ALIGN=CENTER COLSPAN=1>10</TD>
     </TR>
     <TR>
      <TD ALIGN=CENTER COLSPAN=1>Eggs</TD>
      <TD ALIGN=CENTER COLSPAN=1>3</TD>
     </TR>
    </TABLE>

  Suggestions for changes?

John Odom says

  maybe all paragraphs between two || should be considered tables
  rows. To divide paragraphs into columns, a single | could be
  used. For example::

    ||
    this is row 1
    this is row2 column1 | this is row2 column2
    this is row 3
    ||

  should be outputed as::

    <table>
     <tr>
      <td><p>This is row 1</p></td>
     </tr>
     <tr>
      <td><p>This is row2 column 1</p></td>
      <td><p>This is row2 column 2</p></td>
     </tr>
     <tr>
      <td><p>This is row 3</p></td>
     </tr>
    </table>

  I would also like to see a way of indicating column span. Perhaps
  at the end of a paragraph have a number in parathesis. Or if there
  is only whitespace after a | have that column 'swallowed' by the
  preceding column.

Jim --

   I want a table format that looks like a table that I would include in an email.
   Like this::

     Name      Favorite Color
    -------------------------
      Jim         Red
      John        Blue  
    -------------------------

   That might take too much guessing, so something like the following
   might be better::

     |--------------------------|
     |  Name   | Favorite       |
     |         | Color          |
     |==========================|
     | Jim     |  Red           |
     |--------------------------|
     | John    |  Blue          |
     |--------------------------|


   Hm::

     |-------------------------------------------------|
     | Function  | Documentation                       |
     |=================================================|
     | '__str__' | This method converts the            |
     |           |  the object to a string.            |
     |           |                                     |
     |           | - Blah                              |
     |           |                                     |
     |           | - Blaf                              |
     |           |                                     |
     |           |       |--------------------------|  |
     |           |       |  Name   | Favorite       |  |
     |           |       |         | Color          |  |
     |           |       |==========================|  |
     |           |       | Jim     |  Red           |  |
     |           |       |--------------------------|  |
     |           |       | John    |  Blue          |  |
     |           |       |--------------------------|  |
     |-------------------------------------------------|



   These *look* like tables, dang it. Remember, the goal of ST is to
    avoid markup that looks like markup!

Another Suggestion

 I agree with the last remark, that we should avoid markup that looks like markup.  But I think that the amount of ASCII linedrawing required for the last example would become cumbersome. I propose that we implement (possibly in addition to the previous) a way for the StructuredTextNG renderer to make colspan decisions based upon the character column number of the double pipes. I also would like to eliminate extraneous double pipes. Table cells would be broken up based upon which sets of pipes "line up" vertically. For example::

  ||              **Project Status**           ||
  || *My Projects*        || *Team Projects*   ||
  || Project One   || 15% || Project A || 100% ||
  || Project Two   || 50% || Project B ||  10% || 

 ...Should render as:

  ||||||||           **Project Status**            ||
      |||| *My Projects*    |||| *Team Projects*   ||
        || Project One || 15% || Project A || 100% ||
        || Project Two || 50% || Project B ||  10% ||

 Or, as a variation on the previous poster's first idea that might eliminate some of the guesswork: For simple, clean tables, table columns might be determined, again, by examining the character column number of a token character on the dividing line. (In this example, a single space character.) My previous table might now be described like this::

  ================================================ 
                 **Project Status**
  ----------------------- ------------------------
   *My Projects*           *Team Projects*
  ----------------- ----- ----------------- ------
   Project One       15%   Project A         100%
   Project Two       50%   Project B          10%
  ------------------------------------------------

 And the previous poster's "simple table" might look like this::

  ========= ================
   Name      Favorite Color
  --------- ----------------
   Jim       Red
   John      Blue  
  --------------------------

 ...Which would render as:

  || **Name** || **Favorite Color** ||
  || Jim      || Red                ||
  || John     || Blue               ||

 I would imagine that this should not be too hard to implement... I can forsee defining a paragraph as a table if it begins with a line consisting only of '=' and the token character. Heck, I could probably write this functionality myself even being a python newbie. --datagrok (Mike Lamb)


Yet Another Suggestion

  Most tables (I would guess 90%) are simple tables. I think that the
  simpler these tables can be represented, the better. Especially when the
  tables need to be changed, this should be simple. The use of '||' would make
  the editing difficult. Therefore I very much like the last 2 examples
  without the '||'.

  I would want to suggest an even simpler (only for clean simple tables)
  solution:

  Use tabs as column separators. A line that begins with 1 or more non-tabs
  followed by a tab automatically becomes the first row of a table.
  The last example would look like::

    Name      Favorite Color
    Jim       Red
    John      Blue  

  The space in between would have to be tabs. Because I can't see another
  use for tabs in between text, this could work just for tables. Multiple
  tabs wouldn't be a problem either. (Martin)

<hr solid id=comments_below>


gvanrossum (Mar 29, 2001 6:05 pm; Comment #1)  --
 Can somebody explain why the line '||Eggs||3||' appears in a larger, bold font?  it is entered exactly the same as the ||Spam||10|| line before...
 
simon (Jul 11, 2001 5:59 pm; Comment #2)  --
 Yes - the following line ("is interpreted as") was indented, causing the
 eggs line to be treated as a heading.
 
datagrok (Jul 17, 2001 1:58 am; Comment #3)  --
 Martin,
[142 more lines...]