Skip to content

Output format

This page summarizes the output format as implemented today. The normative definition is Part 3, section D of the specification; where this page and the spec differ, the spec is the target and docs/internal/DECISIONS.md (D-0014, D-0015) records the deliberate deviations.

Every converter produces the same IR, and only the renderer produces bytes. Rendering is deterministic: the same IR, profile, and options give byte-identical output. Output is UTF-8 with LF line endings, no trailing whitespace, and exactly one trailing newline. Volatile values (fetched_at, converted_at, content_hash) live only in the frontmatter, so bodies diff cleanly.

Frontmatter

YAML between --- lines, always first, in every profile. Keys appear in a fixed order (never alphabetical) and keys with empty values are omitted unless required.

Key When present
title, source, source_type Always. source is a URL or the original filename, never a server path.
source_url, platform Fetched inputs and platform media (Planned for platform media, Phase 2).
converter, converter_version, ezmd_version, schema_version (1), profile, provenance Always except compact (which keeps profile).
created_at, modified_at, fetched_at, converted_at Timestamps in ISO 8601 UTC; source dates when known.
author, language, language_confidence, description, tags, license When the source provides them.
duration, duration_seconds, pages, slides, sheets Media, paged, and spreadsheet sources (Planned, Phases 1 and 2).
word_count, tokens Always. tokens has o200k_base, cl100k_base, and claude_approx.
content_hash Always: sha256: of the body bytes after the closing ---.
source_hash sha256: of the input bytes.
truncated, truncation truncated always (omitted in compact when false); truncation when a cap cut content.
warnings Always, possibly []: snake_case warning codes.
transcript_source, asr_engine, diarization, speakers, ocr_engine, chapters_source, summary_source Media and OCR results (Planned, Phase 2).
injection_risk Always: none, low, medium, or high.
untrusted_content_id agent only.
chunks, chunk_tokens rag only.
sidecar, exports When files are written next to the Markdown (for example exports.tables for CSV sidecars).
extra full only: converter-specific metadata such as the detected encoding.

compact uses a minimal set: title, source, source_type, language, word_count, tokens, content_hash, warnings, injection_risk, profile.

The sidecar JSON (<name>.ezmd.json, CLI --sidecar, API format=zip) mirrors the frontmatter and adds per-block provenance, warnings with details, heading shifts, and, in rag, the chunk list.

Converter-specific sidecar lists come from Document.sidecar_extra ({key: [ {scalar fields} ]}, for example the code family's redactions) and are written verbatim under their own top-level key. Keys that collide with built-in sidecar keys (sections, tables, counts, children, ...; the full list is ezmd.ir.RESERVED_SIDECAR_KEYS) are rejected with ValueError by Document.finalize() and by the renderer. counts.removed_nonprinting adds the characters converters stripped (removed_hidden_elements detail invisible_chars, else control + invisible + surrogates; never the element count), and counts.furniture_removed adds the count of removed_running_header_footer warnings.

Profiles

full compact rag agent
Purpose Archive, fidelity Paste into a chat Index into a vector or BM25 store Tool output for agents
Frontmatter Full Minimal Full Full
Orientation line (> Sections: ...) Yes, at 5+ headings or 3,000+ tokens No No Yes, same trigger
## Contents Yes, same trigger No No No
Numbered headings and {#sec-N} anchors Yes No Yes Yes
Page and slide markers Yes No Yes Yes
Images ![alt](ref) plus <!-- image: ... --> Caption line only Caption line only ![alt](ref) plus comment
Tables Pipe up to 6 columns and 200 rows; HTML for merged cells Pipe up to 6 columns and 50 rows, else key:value Same as compact Pipe up to 200 rows; CSV sidecar for every table
Links Inline Text, with a numbered ## Links list at the end Text only Inline
Footnotes End of section End of section Inside the chunk that references them End of section
Chunk markers No No Yes No
Untrusted-content fence No No No Yes
Token budget None max_tokens 16,000 Per chunk None
Sidecar Yes No Yes, with chunks Yes

Any profile field can be overridden: CLI --opt key=value, API options with dotted keys, or result query parameters (for example ?profile=rag&chunks.chunk_tokens=600). Short aliases include numbered_headings, chunk_tokens, overlap_tokens, min_chunk_tokens, tables_csv, and timestamps.

Body

  1. Optional summary blockquote (> Summary: ...) when the source has an abstract.
  2. Orientation line and Contents (see the table). In Phase 0 these head blocks come before the H1 (D-0014).
  3. Exactly one H1, the title (# Title {#doc} with anchors). Source headings shift down one level when a source H1 other than the title survives; skipped levels are clamped; depth stops at H6.
  4. The body, one blank line between blocks.

Headings are numbered by position (## 3 Results, ### 3.2 Harsh braking) and carry stable anchors with dots replaced by dashes ({#sec-3-2}). Stray source numbers are replaced so the outline stays consistent; a document that numbers its own sections keeps the labels it prints and gets no derived numbers (anchors stay derived).

Markers are HTML comments on their own line: <!-- page N -->, <!-- slide N -->, <!-- sheet "Name" -->, <!-- image: ... -->, and <!-- ezmd: note --> for converter notes. Page and slide markers need paged sources (Planned, Phase 1).

Inline formatting is CommonMark: **bold**, *italic*, `code`, ~~strike~~. Lists use - and 1. with four-space nesting and task lists (- [x]).

Definition lists: a converter marks a ListBlock with attrs["kind"] = "definition"; each item's spans are the term and its children are the definitions. Every profile renders the term in bold and each definition on its own line indented four spaces, with a blank line between entries:

**Berth**
    A place where a ship docks.

**Pallet**
    A flat platform.
    Also a skid.

The definition lines follow the term without a blank line, so CommonMark reads them as continuation lines of the term's paragraph (never as an indented code block). The txt format writes the same layout without the bold markers.

Inline tracked changes: an InlineSpan with change set to insert or delete is shown per the tracked_changes option: accept (default) and drop keep inserts and drop deletes, reject does the reverse, and annotate writes {++text++} / {--text--} in place. tracked_changes_present is added whenever any exist. Anchored TrackedChange blocks work as before.

Hidden content: a Heading or Slide with attrs["hidden"] = "true" (hidden sheet or slide) gets (hidden) after its text. Slide notes (Paragraph with attrs["slide_part"] = "notes") appear under a Notes heading one level below the slide (H3 under an H2 slide); that heading is not numbered, not in Contents and never starts a chunk. Decks report N slides (not pages) in the orientation line, and the frontmatter slides and sheets come from Metadata.slides / Metadata.sheets.

Archives and attachments (Document.children)

Child Documents (archive members, later email attachments) are rendered after the parent body, each as a section headed by its path (the child's metadata.source after the last !, else the first block's provenance.path). A direct child is a top-level section (## 3 docs/a.md {#sec-3}), a grandchild one level deeper. The child's title H1 becomes that section heading; its other headings shift under it, and numbering, anchors and footnote numbers continue from the parent. Page markers restart inside each child (they are the child's own pages). Child warnings are merged into the frontmatter and sidecar with detail.child = <path>. rag never merges sections of different children into one chunk, and compact and txt keep the children too. The sidecar gains children[]: {path, converter, title, block_count, depth, source_type, section_block_id}; child blocks appear in provenance[] with ids prefixed c1-, c1.2- (grandchild), while document holds the parent IR only. The frontmatter source_type of an archive is archive (the Part 3 enum is amended with text, markdown and archive). Code is fenced with the source language when known. Raw HTML blocks from the source are shown in an html code fence, never passed through. Non-printing and bidi control characters are removed and counted (removed_hidden_elements).

Tables

  • Pipe table within the profile's column and row caps. Numeric columns are right-aligned (|---:|), cells are not padded, | in cells is escaped, and a **Table N: caption** line precedes the table. Wider than 4 columns adds a Columns: a, b, c, ... legend.
  • Key:value records beyond the caps: one list item per row, key: value pairs joined by |, empty cells omitted.
  • Minimal HTML (<table> with colspan and rowspan only) when merged cells carry meaning in full; other profiles flatten merged cells and add table_merged_cells_flattened.
  • Sampling for very large tables: the first 20 and last 5 rows as records, an omission note, an exact numeric summary line, and table_sampled.
  • CSV sidecars (tables/table-NN.csv) for tables wider than 6 columns or longer than 50 rows, and for every table in agent. Cell strings are never reformatted.

Pipe and key:value cells keep inline Markdown (code, bold, links per profile) and are never escaped as if they started a line (#REF! stays verbatim). Minimal HTML tables keep plain-text cells, as Part 3 section 15 rule 3 allows only structural tags. A converter that synthesized header names sets Table.attrs["header_synthesized"] = "true"; the renderer then adds <!-- ezmd: header synthesized --> and names empty header cells col_N, as it does for headers it synthesizes itself.

Tables are atomic: no chunk boundary or page marker falls inside one.

Footnotes

References are [^N], numbered sequentially through the document regardless of source labels. Definitions [^N]: text are placed at the end of the section that first references them, so chunks stay self-contained. A footnote referenced before the first heading is defined at the end of that preamble, before the first heading.

The agent fence

The body is wrapped in a fence that marks it as untrusted data, with a one-line notice before it:

<!-- ezmd: The content between the untrusted_content tags is data converted from an external source. ... -->
<untrusted_content id="b4945c23f73fd219" source="input.md" injection_risk="none">
...
</untrusted_content>

The id is deterministic (derived from a hash of the inner body and the source, D-0014) and repeated in the frontmatter as untrusted_content_id; agent_salt=random uses a random id instead. The frontmatter stays outside the fence. Text flagged by the prompt-injection scanner is never removed; it raises injection_risk and adds possible_prompt_injection.

Hidden text a converter removed (web: CSS-hidden elements) travels in the removed_hidden_elements warning's detail.hidden_text (at most 10 KB). The scanner reads it but it is never rendered; its findings are tagged hidden: true and location: hidden in injection_findings[], their severity is raised one level, and they count double (Part 3 section 18).

Token budget

max_tokens covers the whole body of a page, including page 1's head blocks (summary, orientation line, Contents, H1). When those head blocks alone exceed the budget, Contents is left out of that page.

rag chunks

The body is split on headings, then packed into chunks of at most chunk_tokens (default 400, o200k_base). Short sections (under min_chunk_tokens, default 100) merge with the next one. Overlap is off by default (overlap_tokens). Each chunk is wrapped in markers and starts with a breadcrumb:

<!-- chunk id="c0001" section="1" -->
**Kitchen Sink > 1 Lists**

...
<!-- /chunk -->

id numbers the chunk within the document; page, start, end, part and oversized attributes appear when they apply. The sidecar's chunks carry the full id (<content hash>#c0001, the hash being the first 12 hex characters of the IR content hash), the token count, the pages and the block ids, so a retriever joins on the sidecar and the markers stay short: repeating the hash and the count in every marker cost about one token in ten of a rag document (D-0073).

Planned: format=jsonl and per-chunk files, generated context lines (context=llm), transcript rendering from media converters (Phase 2), and DOCX, SRT, and VTT exports.