StatifierUI.TruthTable.Markdown (StatifierUI v0.3.0)

Copy Markdown View Source

Renders a StatifierUI.TruthTable.t() as Markdown a host hands to Kino.Markdown.new/1.

A pure function over the table, in the shape of StatifierUI.EventLog.Markdown: it names Kino only in this moduledoc and calls nothing under Kino.*, so the same string serves a Livebook cell, a generated docs page, or a test assertion.

Structure

An optional # <title>, the legend, the matrix, and - when any cell failed to evaluate - an error list naming each failure's expression, dataset, and reason. The matrix is a Markdown table: by default one row per dataset and one column per expression, which is the orientation the sui-t0a bead states; orientation: :expressions_as_rows transposes it to the orientation ADR-0006's prose uses. Both describe the same matrix, and neither is derived from the other by the reader, so the axis is an option rather than a decision made here.

The three values stay three

Every cell's text is a spelled-out word - true, false, undefined - and the emphasis around it is added on top, never in place of it. Undefined is italic and false is plain, so the two never look alike at a glance, but a reader who sees no styling at all (a plain-text diff, a terminal, a screen reader) still reads three distinct words. Symbol-only cells were rejected for exactly that reason: a glyph that fails to render is a cell that means whatever the reader assumes, and the assumption is always "false".

Summary

Types

Which axis runs down the table's rows.

Functions

Renders table as a Markdown string.

Types

opt()

@type opt() ::
  {:title, String.t() | nil}
  | {:orientation, orientation()}
  | {:legend, boolean()}
  | {:sources, boolean()}

orientation()

@type orientation() :: :datasets_as_rows | :expressions_as_rows

Which axis runs down the table's rows.

Functions

render(table, opts \\ [])

@spec render(StatifierUI.TruthTable.t(), [opt()]) :: String.t()

Renders table as a Markdown string.

Options:

  • :title - the # heading, or nil for none. Defaults to "Truth table".
  • :orientation - :datasets_as_rows (the default) or :expressions_as_rows. See the moduledoc.
  • :legend - include the three-values legend under the heading. Defaults to true; a page rendering several tables wants it once, not each time.
  • :sources - list each expression's predicator source under the matrix. Defaults to true, because a column header is a name and the name is not the expression.