Double-tagged list <…><…> …

A double-tagged list is a collection of items in which each item starts with two tags (in contrast to starting with a bullet in a bulleted list, a number in a numbered list or a single tag in a single-tagged list). Its tags can be words or phrases.

A double-tagged list is automatically converted to a table when Aneamal text is turned into a webpage. The items’ first tags become row headings, the items’ second tags become column headings and the actual items make up the content of the table. Don’t worry, if this sounds cryptic. You will see how the magic works when you take a look at the examples.

Double-tagged lists are the most basic case of multi-tagged lists which also encompass more complex tables. A simpler kind of table is created from TSV files.

How to

A double-tagged list is a block, so a blank line is expected before and after it unless it occurs at the start or end of a file respectively.

Each item is marked by two tags at the beginning of a line. Each tag is wrapped in angle brackets < >, also known as lower-than and greater-than sign. There must be no space between the first and the second tag, but it is recommended to separate the second tag from the actual item content with a space like in the examples below. Each tag may contain text and phrase markup.

Tags may normally not be empty. There is only one exception: two empty tags <><> can be used to address the origin, the top-left cell in the table, which is independent of all row and column headings.

Any tag pair may only occur once inside a double-tagged list. So you cannot have two items that are both marked with the tags <A><B>. The order of tags matters, however. So <A><B> is different from <B><A> and you can have both tag combinations in the same list as the second example demonstrates.

The actual item after its tags does not need any markup. It can be text with phrase markup though. It can even be a file or a math block.

Examples

The first example compares the number of players and balls in different sports.

<soccer><players> 22
<soccer><balls> 1
<snooker><players> 2
<snooker><balls> 22
<table soccer><players> 2
<table soccer><balls> 1
players balls
soccer 22 1
snooker 2 22
table soccer 2 1

The second example shows how the XOR operator is defined in logic.

<><> XOR
<false><false> false
<false><true> true
<true><false> true
<true><true> false
XOR false true
false false true
true true false

Note

Differently ordered lists can translate to the same table. For instance, the following reordered list results in the same table as the first example:

<soccer><players> 22
<snooker><balls> 22
<snooker><players> 2
<table soccer><players> 2
<soccer><balls> 1
<table soccer><balls> 1
players balls
soccer 22 1
snooker 2 22
table soccer 2 1

It’s an intended property of multi-tagged lists that changing the order of items never changes the interpretation of the list, even if its representation may change.

For developers

When Aneamal is translated to HTML, a double-tagged list is wrapped in an HTML table element. Aneamal tags correspond to HTML th elements, the actual items to td elements. A handful of other HTML elements and attributes are involved. Have a look at the generated code of the examples yourself:

<table>
<colgroup>
<colgroup span='2'>
<thead>
<tr>
<td></td>
<th scope='col'>players</th>
<th scope='col'>balls</th>
</tr>
</thead>
<tbody>
<tr>
<th scope='row'>soccer</th>
<td>22</td>
<td>1</td>
</tr>
<tr>
<th scope='row'>snooker</th>
<td>2</td>
<td>22</td>
</tr>
<tr>
<th scope='row'>table soccer</th>
<td>2</td>
<td>1</td>
</tr>
</tbody>
</table>
<table>
<colgroup>
<colgroup span='2'>
<thead>
<tr>
<td>XOR</td>
<th scope='col'>false</th>
<th scope='col'>true</th>
</tr>
</thead>
<tbody>
<tr>
<th scope='row'>false</th>
<td>false</td>
<td>true</td>
</tr>
<tr>
<th scope='row'>true</th>
<td>true</td>
<td>false</td>
</tr>
</tbody>
</table>

The HTML code may seem more verbose than necessary for the example tables. But keep in mind that double-tagged lists are just the most basic case of multi-tagged lists that can translate to more complex tables. It is useful to have a consistent HTML structure for simple and complex tables, for instance to apply styles without conflict.

The table column which contains the row headings can be selected as colgroup:first-child in CSS, the row that contains the column headings as thead. So the following stylesheet would separate the row and column headings from the table content with lines of medium thickness:

colgroup:first-child {
	border-right: solid medium black;
}
thead {
	border-bottom: solid medium black;
}

Further reading