Mosaic Mosaic 0.9.4

0001 · body format agnosticism

**Status:** Accepted **Date:** 2026-05-19

Status: Accepted Date: 2026-05-19

Context

Base format §5.2 reserves the field name body on a merged Record and defines it as the bytes of a paired text content file (UTF-8). The recognised text-extension set is {.md, .txt, .html, .adoc} (TEXT_BODY_EXTENSIONS in @ssolu/mosaic-core). The spec deliberately stops there: it names the field, says where the bytes come from, and says nothing about how the bytes should be parsed or rendered.

That silence is a position, not an omission. The SEO explainer (spec/profiles/mosaic-web-seo.md §1, "A note on body format") states it explicitly: markdown, HTML, plaintext, and AsciiDoc are equally valid contents for body. The #10 markdown renderer wired into the Astro and Next adapters defaults to treating .md bodies as markdown because that is the most common authoring choice — not because the spec requires it.

We need a recorded decision so future spec changes do not accidentally privilege one format.

Decision

The base format remains format-agnostic about body. Bytes inside body are opaque UTF-8 text. Format dispatch — choosing markdown vs HTML vs plaintext vs AsciiDoc — is an adapter or profile concern, not a base-format concern.

Two dispatch mechanisms are blessed by convention, neither by the base spec:

  1. Extension-based. The file extension that produced the body (.md, .html, .adoc, .txt) drives the adapter's choice of renderer. This is what @ssolu/mosaic-astro and @ssolu/mosaic-next do today.
  2. Discriminator-based. A record MAY carry an optional bodyFormat field (string) when the extension is ambiguous or when the author wants to override. This is a profile/adapter field; the base spec does not enumerate its values or require its presence.

The base spec MUST NOT enumerate body formats beyond TEXT_BODY_EXTENSIONS, and MUST NOT mark one as default. Profiles and adapters declare which formats they support and what their default dispatch is.

Consequences

Alternatives considered

Cross-references