Skip to content

Commit f25d8a2

Browse files
docs: fix link and wrap grammar examples in SPEC (#40)
* docs: fix TOC link in SPEC * docs: wrap array grammar examples in SPEC * fix: missing mustache * docs: fix mustache placement * chore: fix array syntax --------- Co-authored-by: Johann Schopplich <johann@schopplich.com>
1 parent 2bd7b2c commit f25d8a2

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

SPEC.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ https://www.iso.org/standard/70907.html
5757

5858
## Table of Contents
5959

60-
- [Introduction](#introduction)
60+
- [Introduction](#introduction-informative)
6161
1. [Terminology and Conventions](#1-terminology-and-conventions)
6262
2. [Data Model](#2-data-model)
6363
3. [Encoding Normalization (Reference Encoder)](#3-encoding-normalization-reference-encoder)
@@ -427,9 +427,9 @@ Decoding of value tokens follows §4 (unquoted type inference, quoted strings, n
427427
### 9.1 Primitive Arrays (Inline)
428428
429429
- Encoding:
430-
- Non-empty arrays: key[N<delim?>]: v1<delim>v2<delim>… where each vi is encoded as a primitive (Section 7) with delimiter-aware quoting.
431-
- Empty arrays: key[0<delim?>]: (no values following).
432-
- Root arrays: [N<delim?>]: v1<delim>…
430+
- Non-empty arrays: `key[N<delim?>]: v1<delim>v2<delim>…` where each vi is encoded as a primitive (Section 7) with delimiter-aware quoting.
431+
- Empty arrays: `key[0<delim?>]:` (no values following).
432+
- Root arrays: `[N<delim?>]: v1<delim>…`
433433
- Decoding:
434434
- Split using the active delimiter declared by the header; non-active delimiters MUST NOT split values.
435435
- When splitting inline arrays, empty tokens (including those surrounded by whitespace) decode to the empty string.
@@ -438,12 +438,12 @@ Decoding of value tokens follows §4 (unquoted type inference, quoted strings, n
438438
### 9.2 Arrays of Arrays (Primitives Only) — Expanded List
439439
440440
- Encoding:
441-
- Parent header: key[N<delim?>]: on its own line.
441+
- Parent header: `key[N<delim?>]:` on its own line.
442442
- Each inner primitive array is a list item:
443-
- - [M<delim?>]: v1<delim>v2<delim>…
444-
- Empty inner arrays: - [0<delim?>]:
443+
- `- [M<delim?>]: v1<delim>v2<delim>…`
444+
- Empty inner arrays: `- [0<delim?>]:`
445445
- Decoding:
446-
- Items appear at depth +1, each starting with "- " and an inner array header "[M<delim?>]: …".
446+
- Items appear at depth +1, each starting with "- " and an inner array header `[M<delim?>]: …`.
447447
- Inner arrays are split using their own active delimiter; in strict mode, counts MUST match M.
448448
- In strict mode, the number of list items MUST equal outer N.
449449
@@ -455,10 +455,10 @@ Tabular detection (encoding; MUST hold for all elements):
455455
- All values across these keys are primitives (no nested arrays/objects).
456456
457457
When satisfied (encoding):
458-
- Header: key[N<delim?>]{f1<delim>f2<delim>…}: where field order is the first object's key encounter order.
458+
- Header: `key[N<delim?>]{f1<delim>f2<delim>…}:` where field order is the first object's key encounter order.
459459
- Field names encoded per Section 7.3.
460460
- Rows: one line per object at depth +1 under the header; values are encoded primitives (Section 7) and joined by the active delimiter.
461-
- Root tabular arrays omit the key: [N<delim?>]{…}: followed by rows.
461+
- Root tabular arrays omit the key: `[N<delim?>]{…}:` followed by rows.
462462
463463
Decoding:
464464
- A tabular header declares the active delimiter and ordered field list.
@@ -478,19 +478,19 @@ Decoding:
478478
### 9.4 Mixed / Non-Uniform Arrays — Expanded List
479479
480480
When tabular requirements are not met (encoding):
481-
- Header: key[N<delim?>]:
481+
- Header: `key[N<delim?>]:`
482482
- Each element is rendered as a list item at depth +1 under the header:
483-
- Primitive: - <primitive>
484-
- Primitive array: - [M<delim?>]: v1<delim>…
483+
- Primitive: `- <primitive>`
484+
- Primitive array: `- [M<delim?>]: v1<delim>…`
485485
- Object: formatted per Section 10 (objects as list items).
486-
- Complex arrays: - key'[M<delim?>]: followed by nested items as appropriate.
486+
- Complex arrays: `- key'[M<delim?>]:` followed by nested items as appropriate.
487487
488488
Decoding:
489489
- Header declares list length N and the active delimiter for any nested inline arrays.
490490
- Each list item starts with "- " at depth +1 and is parsed as:
491491
- Primitive (no colon and no array header),
492-
- Inline primitive array (- [M<delim?>]: …),
493-
- Object with first field on the hyphen line (- key: … or - key[N…]{…}: …),
492+
- Inline primitive array (`- [M<delim?>]: …`),
493+
- Object with first field on the hyphen line (`- key: …` or `- key[N…]{…}: …`),
494494
- Or nested arrays via nested headers.
495495
- In strict mode, the number of list items MUST equal N.
496496
@@ -501,13 +501,13 @@ For an object appearing as a list item:
501501
- Empty object list item: a single "-" at the list-item indentation level.
502502
- Encoding (normative):
503503
- When a list-item object has a tabular array (Section 9.3) as its first field in encounter order, encoders MUST emit the tabular header on the hyphen line:
504-
- The hyphen and tabular header appear on the same line at the list-item depth: - key[N<delim?>]{fields}:
504+
- The hyphen and tabular header appear on the same line at the list-item depth: `- key[N<delim?>]{fields}:`
505505
- Tabular rows MUST appear at depth +2 (relative to the hyphen line).
506506
- All other fields of the same object MUST appear at depth +1 under the hyphen line, in encounter order, using normal object field rules (Section 8).
507507
- Encoders MUST NOT emit tabular rows at depth +1 or sibling fields at the same depth as rows when the first field is a tabular array.
508508
- For all other cases (first field is not a tabular array), encoders SHOULD place the first field on the hyphen line. A bare hyphen on its own line is used only for empty list-item objects.
509509
- Decoding (normative):
510-
- When a decoder encounters a list-item line of the form - key[N<delim?>]{fields}: at depth d, it MUST treat this as the start of a tabular array field named key in the list-item object.
510+
- When a decoder encounters a list-item line of the form `- key[N<delim?>]{fields}:` at depth d, it MUST treat this as the start of a tabular array field named key in the list-item object.
511511
- Lines at depth d+2 that conform to tabular row syntax (Section 9.3) are rows of that tabular array.
512512
- Lines at depth d+1 are additional fields of the same list-item object; the presence of a line at depth d+1 after rows terminates the rows.
513513
- All other object-as-list-item patterns (bare hyphen, first field on hyphen line for non-tabular values) are decoded according to the general rules in Section 8 and Section 9.
@@ -516,7 +516,7 @@ For an object appearing as a list item:
516516
517517
- Supported delimiters:
518518
- Comma (default): header omits the delimiter symbol.
519-
- Tab: header includes HTAB inside brackets and braces (e.g., [N<TAB>], {a<TAB>b}); rows/inline arrays use tabs.
519+
- Tab: header includes HTAB inside brackets and braces (e.g., `[N<TAB>]`, `{a<TAB>b}`); rows/inline arrays use tabs.
520520
- Pipe: header includes "|" inside brackets and braces; rows/inline arrays use "|".
521521
522522
### 11.1 Encoding Rules (Normative for Encoders)
@@ -1396,9 +1396,9 @@ Non-Serializable Types:
13961396

13971397
Implementations in any language SHOULD:
13981398
1. Document their normalization policy clearly, especially for:
1399-
- Large or arbitrary-precision numbers (lossless string vs. approximate number)
1400-
- Date/time representations (ISO 8601 format details)
1401-
- Collection type mappings (order preservation for sets)
1399+
- Large or arbitrary-precision numbers (lossless string vs. approximate number)
1400+
- Date/time representations (ISO 8601 format details)
1401+
- Collection type mappings (order preservation for sets)
14021402
2. Provide configuration options where multiple strategies are reasonable (e.g., lossless vs. approximate numeric encoding).
14031403
3. Ensure that normalization is deterministic: encoding the same host value twice MUST produce identical TOON output.
14041404

0 commit comments

Comments
 (0)