A string means one thing in a sentence and another in a table cell. Both forms below are in one oath:
The value " ab " has length 6.
Now a table:
| value | length | why |
| - | - | - |
| ' ab ' | 6 | quoted, so the spaces survive |
| ab | 6 | same string, written bare in a cell |
const unquote = (cell: string) => cell.replace(/^'/, '').replace(/'$/, '')
sensor('The value {string} has length {int}.', (_s, value: string) => [value, value.length])
sensor('Now a table:', (_s, table: string[][]) =>
table.slice(1).map(([value, , why]) => [value, unquote(value).length, why])
)
The sentence passes — {string} strips the quotes and preserves the whitespace. The table fails on the bare row only: length: expected 6 but was 2. The cell is trimmed by the table format before the step sees it.
Quoting the cell fixes it, but varar does not strip cell quotes, so each step writes its own unquote.
A suggestion and a question:
- The documentation could mention that tables trim their cells, and that single quotes are needed when whitespace matters.
- Would it be better to require single quotes on all strings in a table cell, with varar stripping them? Then there is no ambiguity, no risk of quotes being missed where they are needed, and cells behave like
{string} does in a sentence.
This issue was edited by Claude
A string means one thing in a sentence and another in a table cell. Both forms below are in one oath:
The sentence passes —
{string}strips the quotes and preserves the whitespace. The table fails on the bare row only:length: expected 6 but was 2. The cell is trimmed by the table format before the step sees it.Quoting the cell fixes it, but varar does not strip cell quotes, so each step writes its own
unquote.A suggestion and a question:
{string}does in a sentence.This issue was edited by Claude