login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

StructuredText supports tables with a simpler markup than HTML using this markup:

  |-------|
  |h1 |h2 |
  |=======|
  | a | b |
  |-------|
  | c | d |
  |-------|

which renders as:

h1

h2

a

b

c

d

Also, Structured Text in ZWiki supports this variant; the + at the corners makes it easier to edit in Emacs. It may not be worth deviating from the standard though:

 +---+---+
 | a | b |
 +---+---+
 | c | d |
 +---+---+

Renders as:

a

b

c

d

You can influence horizontal and vertical justification by positioning your text within the cell. Also, you can use a wider cell when you need to. Other variations may cause Structured Text not to recognize the table or even give an error.

If you're editing these a lot, you definitely want help from something like picture-mode. There's also table.el . In some cases it may be quicker to use :: and fixed width text, as above.

Notes and examples

(from FranOReilly?)

Basically, you need to "draw" the table borders and cell borders with | and - characters. The important bits are that the first and last lines are |---------------| to represent the top and bottom borders and row separators; that the left and right borders of each row are bounded by | and that cells are separated by |. Although it doesn't seem to be very fussy about exact alignment, it is probably best to make sure the rows, columns line up correctly at least for readers of the code.

Here are three examples:

 |--------------------------|
 | Col1 | Col2 | col3       |
 |--------------------------|
 |This is a spanning row    |
 |--------------------------|
 |Cell1 | Cell 2 | Cell 3   |
 |--------------------------|

Col1

Col2

col3

This is a spanning row

Cell1

Cell 2

Cell 3

This one is a table with table headers (the first row separator line is made of = characters:

 |--------------|
 |Date | Time   |
 |==============|
 |20/5 | 12:00  |
 |--------------|
 |21/5 | 13:15  |
 |--------------|

Date

Time

20/5

12:00

21/5

13:15

Here is an example of a table embedded in a table from the StructuredTextWiki:StructuredTextNGRules:

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

Function

Documentation

__str__

This method converts the the object to a string.

  • Blah
  • Blaf

    Name

    Favorite Color

    Jim

    Red

    John

    Blue

The generated tables aren't very compact or pretty.

Nested Example :

 +------------------------+
 | <center>               |
 |  Top-o-the-World,      |
 |                        |
 |    MA!!!</center>      |
 +========================+
 |                        |
 |                        |
 | +-------------------+  |
 | |                   |  |
 | |       self        |  |
 | |                   |  |
 | | +---------------+ |  |
 | | |               | |  |
 | | |  centered?    | |  |
 | | |               | |  |
 | | +---------------+ |  |
 | |                   |  |
 | +-------------------+  |
 |                        |
 +------------------------+

renders as:

Top-o-the-World,

MA!!!

self

centered?

The "+" way doesn't need the right wall of the box, although it needs all 4 corners. This leads to some interesting possibilities...

hmmm... This should be a stx table

eratic block endings:

a

b

c

d




  Subject:   Be Bold !!
  ( 15 subscribers )  
Please rate this page: