Cite.Source (Cite v0.2.0)

Copy Markdown View Source

The document as the caller's list of passages. Built by Cite.source/2, which documents as and show. Only the meta keys show names reach the model. The rest of meta stays with the caller.

Shown meta goes on the wire, so its values must be JSON: nil, booleans, atoms, numbers, UTF-8 binaries, and lists and plain maps of these, with atom or binary keys. A map may not hold a key as both an atom and a string (:k and "k"): on the wire they are one key.

Summary

Functions

Builds a source from units, each a text or %{text: text} with optional :id and :meta. Text is kept byte for byte. A unit without an id gets one from its position in the list: P000, P001, and so on. Raises ArgumentError on a unit, id, text, shown meta value, or option it cannot use.

Types

t()

@type t() :: %Cite.Source{
  as: String.t(),
  passages: [Cite.Passage.t()],
  show: [atom() | String.t()]
}

Functions

new(units, opts \\ [])

@spec new([String.t() | map()], keyword()) :: t()

Builds a source from units, each a text or %{text: text} with optional :id and :meta. Text is kept byte for byte. A unit without an id gets one from its position in the list: P000, P001, and so on. Raises ArgumentError on a unit, id, text, shown meta value, or option it cannot use.