Skip to content

[fm-var] Implement one-sequence fm-list rendering #119

Description

@DandyLyons

Problem / outcome

Implement RFC 001 Rev 3 <fm-list> evaluation/rendering for a JSONPath query that selects exactly one one-dimensional scalar YAML sequence, including split empty/null fallbacks and whole-list atomic failure.

Epic: #111. Milestone: 3 — Formatting and lists.

In scope

  • Require a nodelist containing exactly one sequence node; $.steps is valid while $.steps[*] selects members and is a cardinality/shape error.
  • Extract only the selected sequence's immediate members, preserving order and duplicates without recursive flattening.
  • Apply default-zero to zero selected nodes or an empty selected sequence.
  • Apply default-null to a selected null node or a sequence containing only null members.
  • Reject multiple selected nodes, scalar/mapping selections, mixed null/scalar sequences, nested sequences/mappings, and any invalid member atomically.
  • Apply item-type coercion to every valid scalar member.
  • Render ordered/unordered success caches as exact list HTML and inline formats through locale-aware list formatting.
  • Render block or inline fallbacks as escaped literal text with no list/list-item wrapper.
  • Compare existing caches for freshness without trusting child markup.

Relevant specification sections

  • §2.2 <fm-list> Rev 3 attributes, placement, formats, styles, and fallback cache shape.
  • §2.3 array defaults/cascade.
  • §3.6–3.9 cardinality, shape, split fallback, formatting, and escaping.
  • §8 list-result rationale.

Dependencies and blockers

Implementation considerations

  • Reuse scalar coercion per item but stage every result before emitting an edit.
  • Successful block serialization permits only required list/list-item markup; fallback serialization uses scalar-cache text escaping.
  • Keep locale-sensitive adapters isolated from portable cardinality/shape/fallback semantics.
  • Record query nodelist cardinality, selected sequence metadata, effective locale/style, and failure member location for explain output.

Acceptance Criteria

  • Exactly one selected sequence succeeds; zero, null, multi-node, and wrong-shape outcomes follow their distinct Rev 3 rules.
  • Empty sequences use default-zero/unresolved-zero; all-null sequences use default-null/unresolved-null.
  • Mixed-null, nested, mapping, or invalid members retain the complete prior cache with stable diagnostics.
  • Sequence order and duplicate members are preserved.
  • Ordered/unordered successes emit only canonical HTML; block fallbacks emit only escaped literal text.
  • Inline formats/styles and item-type behave consistently and atomically.
  • Member/fallback text cannot inject HTML/Markdown or close an fm-var element.

Test requirements

  • Language-neutral fixtures for $.items versus $.items[*], nodelist cardinality, empty/all-null/mixed-null, shape/coercion, duplicates/order, split fallbacks, atomic failure, escaping, and block structure.
  • Fixed-locale tests for list types/styles, one/two/many items, Unicode, and Apple/Linux behavior.

Documentation / CLI-help impact

  • Examples for query-to-sequence semantics, both fallbacks, all five formats, three inline styles, locale requirements, and block placement/fallback shape.

Explicitly deferred

  • Rendering arbitrary JSONPath nodelists directly, recursive flattening, mappings, custom item templates, Markdown list-marker caches, and arbitrary child markup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions