|
|
last edited 17 years ago |
1 | ||
Editor:
Time: 2007/11/18 18:38:58 GMT-8 |
||
Note: |
changed: - 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":http://table.sourceforge.net/ . 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: +------------------------+ | <center> | | Top-o-the-World, | | | | MA!!!</center> | +========================+ | | | +-------------------+ | | | | | | | 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 | |-------|
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.
(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 |
||||||
---|---|---|---|---|---|---|---|
|
This method converts the the object to a string.
|
The generated tables aren't very compact or pretty.
Nested Example :
+------------------------+ | <center> | | Top-o-the-World, | | | | MA!!!</center> | +========================+ | | | | | +-------------------+ | | | | | | | self | | | | | | | | +---------------+ | | | | | | | | | | | centered? | | | | | | | | | | | +---------------+ | | | | | | | +-------------------+ | | | +------------------------+
renders as:
MA!!! |
||
---|---|---|
|
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 |