Tables

Tables are made up of cells arranged in rows. These are handled by always creating each cell, then instructing the software what to fill it with. This is either content or an instruction to merge it with another cell.

How it works

Add the $TABLE tag to each line to be included in the table. This instructs the book reader to render the row of a table. Each cell is indicated using square brackets with content inside it.

$TABLE {{R1, C1}} {{R1, C2}} {{R1, C3}}
$TABLE {{R2, C1}} {{R2, C2}} {{R2, C3}}
$TABLE {{R3, C1}} {{R3, C2}} {{R3, C3}}

This would create something like the following:

R1, C1 R1, C2 R1, C3
R2, C1 R2, C2 R2, C3
R3, C1 R3, C2 R3, C3

Merging columns

To merge columns you instruct the next column(s) along to merge using the $MERGE tag.

$TABLE {{R1, C1}} {{R1, C2}} {{R1, C3}}
$TABLE {{R2, C1}} {{$MERGE}} {{R2, C3}}
$TABLE {{R3, C1}} {{R3, C2}} {{R3, C3}}

This would create the following:

R1, C1 R1, C2 R1, C3
R2, C1 R2, C3
R3, C1 R3, C2 R3, C3

In the second row, the first and second columns have merged.

Note: the $MERGE tag always looks left, so make sure to fill the first column with something.

Merging rows

To merge a row you instruct the cell below to merge with the cell above using the $MERGEUP tag.

$TABLE {{R1, C1}} {{R1, C2}} {{R1, C3}}
$TABLE {{$MERGEUP}} {{R2, C2}} {{R2, C3}}
$TABLE {{R3, C1}} {{R3, C2}} {{R3, C3}}

This would create the following:

R1, C1 R1, C2 R1, C3
R2, C2 R2, C3
R3, C1 R3, C2 R3, C3

The first cells in the first two rows are now merged.

Note: the $MERGEUP tag always looks up, so make sure to fill the first cell with content and leave the ones below empty.

Empty cells

Use the square brackets with blank content.

$TABLE {{}} {{R1, C2}} {{R1, C3}}
$TABLE {{R2, C1}} {{R2, C2}} {{R2, C3}}
$TABLE {{R3, C1}} {{R3, C2}} {{R3, C3}}

This would create the following:

  R1, C2 R1, C3
R2, C1 R2, C2 R2, C3
R3, C1 R3, C2 R3, C3

Table headers

Use the special tag $H before a cell to indicate it is a header.

$TABLE $H{{R1, C1}} {{$MERGE}} {{$MERGE}}
$TABLE {{R2, C1}} {{R2, C2}} {{R2, C3}}
$TABLE {{R3, C1}} {{R3, C2}} {{R3, C3}}

This would create something like the following:

R1, C1
R2, C1 R2, C2 R2, C3
R3, C1 R3, C2 R3, C3

Complex content

Tables can easily manage complex content like paragraphs and other block level elements.

$TABLE A table containing block-level content
$TABLE {{This contains paragraphs.

Paragraph 2.

Paragraph 3.}} // End of first cell
{{$MERGE}}
{{Third cell contains a bullet point list:
* Bullet 1
* Bullet 2
* Bullet 3}} // End of first row
$TABLE {{Paragraph 1.

Paragraph 2.

Paragraph 3.}}
{{Paragraph 1.

Paragraph 2.

Paragraph 3.}}
{{Paragraph 1.

Paragraph 2.

Paragraph 3.}} // End of second row
$TABLE {{A numbered list:
1. Item 1
2. Item 2
3. Item 3}}
{{Paragraph 1.

Paragraph 2.

Paragraph 3.}}
{{$MERGE}}
// This blank line is needed to end the table
 
This is normal content i.e. a paragraph.

A table containing block-level content

This contains paragraphs.

Paragraph 2.

Paragraph 3.

Third cell contains a bullet point list:

  • Bullet 1
  • Bullet 2
  • Bullet 3

Paragraph 1.

Paragraph 2.

Paragraph 3.

Paragraph 1.

Paragraph 2.

Paragraph 3.

Paragraph 1.

Paragraph 2.

Paragraph 3.

A numbered list:

  1. Item 1
  2. Item 2
  3. Item 3

Paragraph 1.

Paragraph 2.

Paragraph 3.

Captions and summaries

Web languages use special tags to add a caption and summary to tables. In brief, a caption is a special heading to introduce the contents of a table and is usually visible to the reader. A summary is a hidden field that describes the content of the table for those using assisitive technologies, such as the blind.

Simply use the $TABLE tag with normal text and no square brackets. If it is at the top of the table it is treated as a visible visible caption. If it is the last line it is treated as the hidden summary.

$TABLE This is the visible caption
$TABLE {{R1, C1}} {{R1, C2}} {{R1, C3}}
$TABLE {{R2, C1}} {{R2, C2}} {{R2, C3}}
$TABLE {{R3, C1}} {{R3, C2}} {{R3, C3}}
$TABLE This is treated as a hidden summary for screen readers
Note: Captions and summaries can only appear on the first row or the last. If they are used within a table they are ignored.

Leave a Reply

Your email address will not be published. Required fields are marked *