Multi-line, indented .dxn rendering — Dextrin.encode/2's
pretty: true opt, mix dextrin.format's --mode pretty, and mix dextrin.decode's default output (a CLI decode is a human reading
the result, so encode/2's own single-line default isn't the right
default there). --mode condense needs no separate implementation
at all: it's exactly what Dextrin.encode/2/Dextrin.Text.Printer
already produce with pretty: false (the default).
The layout (Jan, 2026-10-20): the top-level collection always
breaks, one entry per line, however short it is. A nested collection
is written on one line, its entries single-space separated, when that
line -- its indent and its key included -- fits the width (:width,
80); otherwise it breaks too, and what it holds is laid out again
by the same rule.
A value has no comments, so this formatter has none to keep. To lay
out a document and keep its comments, parse it as a
Dextrin.Document and use Dextrin.Document.format/2, which lays a
comment-free document out exactly as this module lays out its value.
Summary
Functions
Renders value as multi-line, indented .dxn text. Returns
{:ok, _} | {:error, _}, matching Dextrin.Text.Printer.print/2 —
the only way this can fail is the same as print/2's: a struct with
no tag_encoder/schema module registered (or one that itself
returns {:error, _}).
Functions
@spec pretty(term(), keyword()) :: {:ok, String.t()} | {:error, Dextrin.Error.t()}
Renders value as multi-line, indented .dxn text. Returns
{:ok, _} | {:error, _}, matching Dextrin.Text.Printer.print/2 —
the only way this can fail is the same as print/2's: a struct with
no tag_encoder/schema module registered (or one that itself
returns {:error, _}).
opts[:indent] sets the number of spaces per nesting level (default
2), and opts[:width] the columns a nested
collection's one line must fit in (default 80); every
other opt (registry:, ...) is the same as print/2's.