Ascii.Render.HTML (Ascii v0.3.0)

Copy Markdown View Source

A frame as the inside of a <pre>: escaped text, and for a coloured frame a <span style="color:..."> a run of one colour. A run whose colour is nil (in no coloured part, see Ascii.Parts) is plain text, in the page's own; one in a CSS variable (see Ascii.Ink) takes the page's value for it.

Spaces join whatever run they fall in, so a logo is a few dozen spans and a full scene a few thousand. That is fine for a still or a logo; to play a piece live, Ascii.Phoenix.PlayerLive sends only what changes.

Phoenix is not needed: the result is plain iodata, already escaped. Put it in a <pre> whose style is style/1.

Summary

Functions

HTML-escapes text (as iodata).

The <pre>'s contents, escaped: rows/1 joined by newlines.

Row y's HTML, as in rows/1.

Each row's HTML, escaped, without newlines.

The <pre>'s style: the piece's ground behind a coloured frame, else nil.

Functions

escape(text)

@spec escape(text :: iodata()) :: iodata()

HTML-escapes text (as iodata).

render(frame)

@spec render(frame :: Ascii.Frame.t()) :: iodata()

The <pre>'s contents, escaped: rows/1 joined by newlines.

row(frame, y)

@spec row(frame :: Ascii.Frame.t(), y :: non_neg_integer()) :: iodata()

Row y's HTML, as in rows/1.

rows(frame)

@spec rows(frame :: Ascii.Frame.t()) :: [iodata()]

Each row's HTML, escaped, without newlines.

style(frame)

@spec style(frame :: Ascii.Frame.t()) :: String.t() | nil

The <pre>'s style: the piece's ground behind a coloured frame, else nil.