cottax.consumers.visualization.naming module

How a drawing writes a name: the plain formatter, a name as shown, and its markup.

type Notations = Mapping[type[Mint], Notation]

A formatter’s own notation per purpose, by its Mint class, over the `MintDrawing`s.

notation_of(notations: Notations, m: Mint, medium: str, otherwise: str)[source]

m’s notation in medium (‘plain’, ‘latex’): the formatter’s own along its class’s ancestry, else its MintDrawing’s, else otherwise around its spelling.

Return type:

Notation

class CopyDrawing[source]

Bases: MintDrawing

A cut’s copy wears a hat: hat{y}.

plain: AbstractVar[Notation] = Around()
latex: AbstractVar[Notation] = Accent()
class PlainFormat(notation: Notations | None = None)[source]

Bases: Formatter

Every name by spell_plain, a minted one in its purpose’s notation (notation keyed by the Mint class, else its MintDrawing), else as <spelling>(·) – what a drawing writes unless told otherwise.

spell(path: Label)[source]
Return type:

str

set(source: str)[source]
Return type:

str

label(text: str)[source]
Return type:

str

text(text: Text)[source]
Return type:

str

outright(path: Label)[source]
Return type:

bool

notation(m: Mint)[source]
Return type:

Notation

type Shown = tuple[str, str | None]

What a drawing sets for a name: its markup, and the mark drawn over it (or None).

MARKS = {'bar': '̄', 'dot': '̇', 'hat': '̂', 'tilde': '̃'}

Each mark as a combining character, for a medium that cannot draw it.

shown(path: Label, formatter: Formatter)[source]

path as a drawing sets it: the formatter’s own name for it where it gives one (outright), else its namespace’s notation over what it stands for (recursively: a mint over a mint), else its spelling. Decided once, here, for every drawing.

Return type:

Shown

marked(name: Shown)[source]

A shown name as one run of markup, its mark a combining character on the first letter of its text – for a medium that cannot draw the mark itself.

Return type:

str

MARKUP = '\x01'

What a Formatter wraps around a spelling it has already set as markup.

<I>, <B>, <SUB>, <SUP>, <FONT FACE=”…”> and the XML entities are what a marked run may hold; any other tag is dropped and its text kept, so an unknown one is legible rather than fatal. x01 cannot occur in a name and never reaches the drawing.

markup_html(s: str)[source]

Markup as HTML, for a page’s tooltip and key: a name escaped as the text it is, a marked run’s <I>, <B>, <SUB>, <SUP> kept as the HTML they already are, and a named face a <span> in it.

Return type:

str