Fit Specification

# Fit Specification: Annotation

This portion of the Fit specification describes how Fit can modify, or “annotate,” HTML documents.

Contents:

Text.. 1

Adding Text 2

Tags. 2

Cell Tags. 2

Row Tags. 4

Table Tags. 4

Table Structure. 5

Cells. 5

Rows. 6

Tables. 6

Standard Annotations. 7

HTML Conversion. 8

Markup Removal 8

Text to HTML. 9

Entities. 9

Line Feeds. 9

Spaces. 10

Run Results. 10

## Text

Fixtures may change the body of any individual cell in their table.

fat.AnnotationFixture |  |  |  |
OriginalHTML | Row | Column | OverwriteCellBody | ResultingHTML()
<table> <tr><td>top left</td><td>top right</td></tr> <tr><td>bottom left</td><td>bottom right</td></tr> </table> | 1 | 1 | new value | <table> <tr><td>new value</td><td>top right</td></tr> <tr><td>bottom left</td><td>bottom right</td></tr> </table>
| 2 | 2 | another value | <table> <tr><td>top left</td><td>top right</td></tr> <tr><td>bottom left</td><td>another value</td></tr> </table>

The raw HTML provided by the fixture is inserted into the table. (Fixtures may also ask for text to HTML conversion as described below.)

fat.AnnotationFixture |  |  |  |
OriginalHTML | Row | Column | OverwriteCellBody | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | 1 | 1 | <b><i>Excited text!</i></b> | <table> <tr><td><b><i>Excited text!</i></b></td></tr> </table>

### Adding Text

Fixtures may add text to the body of a cell rather than simply overwriting it.

fat.AnnotationFixture |  |  |  |
OriginalHTML | Row | Column | AddToCellBody | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | 1 | 1 | ... more text | <table> <tr><td>text... more text</td></tr> </table>

## Tags

Fixtures may manipulate tags as well as text.

### Cell Tags

Fixtures may overwrite cell tags.

fat.AnnotationFixture |  |  |  |
OriginalHTML | Row | Column | OverwriteCellTag | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | 1 | 1 | <td align=”right”> | <table> <tr><td align=”right”>text</td></tr> </table>
<table> <tr><td old=”foo”>text</td></tr> </table> | 1 | 1 | <td new=”bar”> | <table> <tr><td new=”bar”>text</td></tr> </table>

They may also add to cell tags. We’ve delimited the “AddToCellTag” column in this example with brackets so we can include a leading space. Fit doesn’t add spaces for you when you add to a tag.

fat.AnnotationFixture |  |  |  |
OriginalHTML | Row | Column | AddToCellTag | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | 1 | 1 | [ align=”right”] | <table> <tr><td align=”right”>text</td></tr> </table>
<table> <tr><td old=”foo”>text</td></tr> </table> | 1 | 1 | [ new=”bar”] | <table> <tr><td old=”foo” new=”bar”>text</td></tr> </table>
| 1 | 1 | [no-added-space] | <table> <tr><td old=”foo”no-added-space>text</td></tr> </table>

Fixtures can even change the type of the tag. If they don’t specify an ending tag, they’ll create a mismatched tag. Fit doesn’t prevent fixtures from intentionally creating mismatched tags either.

fat.AnnotationFixture |  |  |  |  |
OriginalHTML | Row | Column | OverwriteCellTag | OverwriteEndCellTag | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | 1 | 1 | <foo> |  | <table> <tr><foo>text</td></tr> </table>
| 1 | 1 | <bar> | </bar> | <table> <tr><bar>text</bar></tr> </table>
| 1 | 1 | <foo> | </bar> | <table> <tr><foo>text</bar></tr> </table>

### Row Tags

All of this applies equally to row tags...

fat.AnnotationFixture |  |  |  |  |
OriginalHTML | Row | OverwriteRowTag | OverwriteEndRowTag | AddToRowTag | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | 1 | <tr valign=”true”> |  |  | <table> <tr valign=”true”><td>text</td></tr> </table>
| 1 | <bar> | </bar> |  | <table> <bar><td>text</td></bar> </table>
| 1 | <foo> | </bar> | [ attrib=”yes”] | <table> <foo attrib=”yes”><td>text</td></bar> </table>

### Table Tags

...and to table tags.

fat.AnnotationFixture |  |  |  |
OriginalHTML | OverwriteTableTag | OverwriteEndTableTag | AddToTableTag | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | <table border=”1”> |  |  | <table border=”1”> <tr><td>text</td></tr> </table>
| <bar> | </bar> |  | <bar> <tr><td>text</td></tr> </bar>
| <foo> | </bar> | [ attrib=”yes”] | <foo attrib=”yes”> <tr><td>text</td></tr> </bar>

## Table Structure

In addition to being able to modify table contents, fixtures may also change the structure of tables in any way they wish. The following examples show basic possibilities, but any manipulation is possible.

### Cells

Fixtures may add cells.

fat.AnnotationFixture |  |  |  |
OriginalHTML | Row | Column | AddCellFollowing | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | 1 | 1 | <td>new cell</td> | <table> <tr><td>text</td><td>new cell</td></tr> </table>
<table> <tr><td>text</td><td>last cell</td></tr> </table> | 1 | 1 | <td>yadda</td> | <table> <tr><td>text</td><td>yadda</td><td>last cell</td></tr> </table>

Fixtures may remove cells.

fat.AnnotationFixture |  |  |  |
OriginalHTML | Row | Column | RemoveFollowingCell | ResultingHTML()
<table> <tr><td>text</td><td>yadda</td><td>last cell</td></tr> </table> | 1 | 1 | yes | <table> <tr><td>text</td><td>last cell</td></tr> </table>
<table> <tr><td>text</td><td>yadda</td><td>last cell</td></tr> </table> | 1 | 2 | yes | <table> <tr><td>text</td><td>yadda</td></tr> </table>

### Rows

They can add rows.

fat.AnnotationFixture |  |  |
OriginalHTML | Row | AddRowFollowing | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | 1 | <tr><td>new row</td></tr> | <table> <tr><td>text</td></tr><tr><td>new row</td></tr> </table>

...and remove rows.

fat.AnnotationFixture |  |  |
OriginalHTML | Row | RemoveFollowingRow | ResultingHTML()
<table> <tr><td>text</td></tr> <tr><td>second row</td></tr> </table> | 1 | yes | <table> <tr><td>text</td></tr> </table>

### Tables

Fixtures can even add entire tables.

fat.AnnotationFixture |  |
OriginalHTML | AddTableFollowing | ResultingHTML()
<table> <tr><td>text</td></tr> </table> | <table><tr><td> new table </td></tr></table> | <table> <tr><td>text</td></tr> </table><table><tr><td> new table </td></tr></table>

## Standard Annotations

Fit provides some “short-cut” annotations for fixtures to use. They have standard meanings:

· right: Fit checked the cell against the software and the software gave the correct answer.

· wrong: Fit checked the cell against the software and the software gave the wrong answer.

· error: Fit checked the cell against the software and the software generated a run-time error (e.g., an exception).

· info: Fit added information to the cell. (Typically used when a cell was blank to start with.)

· ignore: Fit ignored the cell entirely.

fat.StandardAnnotationFixture |  |  |  |
OriginalHTML | Annotation | Text | Output() | RenderedOutput()
<td>text</td> | right | (none) | <td bgcolor="#cfffcf">text</td> |
text
| wrong | actual result | <td bgcolor="#ffcfcf">text <font size=-1 color="#c08080"><i>expected</i></font><hr>actual result <font size=-1 color="#c08080"><i>actual</i></font></td> |
text expected actual result actual
| error | error message | <td bgcolor="#ffffcf">text<hr><pre>error message</pre></td> |
text
    error message
| info | value | <td>text <font color="#808080">value</font></td> |
text value
| ignore | (none) | <td bgcolor="#efefef”>text</td> |
text

### HTML Conversion

New text provided by the fixture is converted from text to HTML as described in the “Text to HTML” section below. This doesn’t apply to “right” and “ignore” annotations, which don’t add any text.

fat.StandardAnnotationFixture |  |  |  |
OriginalHTML | Annotation | Text | Output() | RenderedOutput()
<td>text</td> | wrong | A <p> tag | <td bgcolor="#ffcfcf">text <font size=-1 color="#c08080"><i>expected</i></font><hr>A &lt;p> tag <font size=-1 color="#c08080"><i>actual</i></font></td> |
text expected A <p> tag actual
| error |  | <td bgcolor="#ffffcf">text<hr><pre>A &lt;p> tag</pre></td> |
text
    A <p> tag
| info |  | <td>text <font color="#808080">A &lt;p> tag</font></td> |
text A <p> tag

### Markup Removal

When annotating “wrong” and “error” cells, Fit strips mark-up from the existing contents of the cell so troubleshooting is easier. It doesn’t do so for other annotations.

fat.StandardAnnotationFixture |  |  |  |
OriginalHTML | Annotation | Text | Output() | RenderedOutput()
<td><ul><li>text</li></ul></td> | right | blank | <td bgcolor="#cfffcf"><ul><li>text</li></ul></td> |
text
| wrong | actual result | <td bgcolor="#ffcfcf">text <font size=-1 color="#c08080"><i>expected</i></font><hr>actual result <font size=-1 color="#c08080"><i>actual</i></font></td> |
text expected actual result actual
| error | error message | <td bgcolor="#ffffcf">text<hr><pre>error message</pre></td> |
text
    error message
| ignore | blank | <td bgcolor="#efefef”><ul><li>text</li></ul></td> |
text
| info | value | <td><ul><li>text</li></ul> <font color="#808080">value</font></td> |
text value

Although other mark-up is stripped, line breaks are preserved.

fat.StandardAnnotationFixture |  |  |  |
OriginalHTML | Annotation | Text | Output() | RenderedOutput()
<td><ul><li>line<br>break</li></ul></td> | wrong | actual result | <td bgcolor="#ffcfcf">line<br />break <font size=-1 color="#c08080"><i>expected</i></font><hr>actual result <font size=-1 color="#c08080"><i>actual</i></font></td> |
line break expected actual result actual
| error | error message | <td bgcolor="#ffffcf">line<br />break<hr><pre>error message</pre></td> |
line break
    error message

## Text to HTML

Fixtures may ask Fit to convert a string to HTML.

### Entities

Some characters are turned into entities.

fat.TextToHtmlFixture |
Text | HTML()
< | &lt;
& | &amp;

### Line Feeds

ASCII line feed codes are turned into HTML break tags. (In these examples, “\n” is ASCII 10, “new line”, and “\r” is ASCII 13, “carriage return.”)

fat.TextToHtmlFixture |
Text | HTML()
Unix \n line feed | Unix <br /> line feed
Mac \r line feed | Mac <br /> line feed
DOS \r\n line feed | DOS <br /> line feed
Backwards \n\r line feed is seen as two line feeds | Backwards <br /><br /> line feed is seen as two line feeds

### Spaces

Multiple adjoining spaces are turned into &nbsp; entities.

fat.TextToHtmlFixture |
Text | HTML()
1 2 | 1 &nbsp; &nbsp; 2

## Run Results

fit.Summary
counts | 47 right, 0 wrong, 0 ignores, 0 exceptions
input file | spec/input/annotation.html
input update | Sun Apr 17 21:00:13 2005
output file | spec/output/annotation.html
run date | Wed Apr 27 16:11:56 2005
run elapsed time | 0 wallclock secs ( 0.08 usr + 0.00 sys = 0.08 CPU)