[REBOL] Re: make-doc-pro: how to handle tables?
From: al:bri:xtra at: 22-Sep-2001 8:21
Robert wrote:
> Hi, I'm going to add table support to make-doc-pro. I'm interested in your
opinion how to do it and what syntax to use. Currently I'm thinking about
something like this:
> first cell | second cell | last cell
> second line| ...
>
> What do you think?
I quite like:
first cell second cell last cell
second line
where the large spaces are tab characters.
Which can be expressed in a eText rule much like:
Table: make object! [
Type: 'TH
Mark: #"|"
NonBar: exclude Printable charset to-string Mark
Cells: make block! 10
BarCell: [Mark Align copy Line some NonBar]
TabCell: [copy Line some Printable Line]
Append-Cell: does [
repend Cells [make path! reduce [Type Align!/Type] Inline Line]
]
Row: [
[
[
opt [some [Mark some #"-"] opt Mark newline]
some [BarCell (Append-Cell)]
opt Mark
]
| Align TabCell (Append-Cell) some [
tab Align TabCell (Append-Cell)
]
] newline
]
Rows: make block! 10
Rule: [
opt Empty
(
Type: 'TH
Rows: make block! 10
Cells: make block! 10
)
some [
Row (
repend Rows ['TR Cells]
Type: 'TD
Cells: make block! 10
)
](
repend Block ['Table Rows]
)
]
]
and seems to work quite well for me.
Andrew Martin
ICQ: 26227169 http://zen.scripterz.org