math_spec.typesetting.format
The seam between what a model says and how a format spells it.
The split, and each module's role in it, are in README.md beside this file.
NOTATIONS = frozenset(get_args(Notation))
module-attribute
#
Notation = Literal['latex', 'typst']
module-attribute
#
OPERATOR_NAMES = frozenset(get_args(OperatorName))
module-attribute
#
OPERATOR_SPELLINGS = {'cdot': ('\\cdot', 'dot'), 'plus': ('+', '+'), 'minus': ('-', '-'), 'equal': ('=', '='), 'le': ('\\le', '<='), 'ge': ('\\ge', '>='), 'lt': ('<', '<'), 'gt': ('>', '>'), 'ne': ('\\neq', '!='), 'in': ('\\in', 'in'), 'and': ('\\wedge', 'and'), 'or': ('\\vee', 'or'), 'not': ('\\neg', 'not'), 'false': ('\\bot', 'bot'), 'forall': ('\\forall\\,', 'forall'), 'such_that': ('\\,:\\,', 'colon'), 'infinity': ('\\infty', 'infinity'), 'cyclic_minus': ('\\ominus', 'minus.o'), 'cyclic_plus': ('\\oplus', 'plus.o'), 'edge_minus': ('\\boxminus', 'minus.square'), 'edge_plus': ('\\boxplus', 'plus.square'), 'times': ('\\times', 'times'), 'maps_to': ('\\to', 'arrow.r'), 'reals': ('\\mathbb{R}', 'RR'), 'integers': ('\\mathbb{Z}', 'ZZ'), 'binary_set': ('\\{0, 1\\}', '{0, 1}'), 'sos_set': ('\\mathrm{SOS}', 'upright("SOS")'), 'position': ('\\mathrm{pos}', 'upright("pos")'), 'minimize': ('\\min', 'min'), 'maximize': ('\\max', 'max')}
module-attribute
#
OperatorName = Literal['cdot', 'plus', 'minus', 'equal', 'le', 'ge', 'lt', 'gt', 'ne', 'in', 'and', 'or', 'not', 'false', 'forall', 'such_that', 'infinity', 'cyclic_minus', 'cyclic_plus', 'edge_minus', 'edge_plus', 'times', 'maps_to', 'reals', 'integers', 'binary_set', 'sos_set', 'position', 'minimize', 'maximize']
module-attribute
#
Entry(symbol, meaning)
dataclass
#
Format
#
Bases: Protocol
How one output format spells what a walk emits.
cases_row
class-attribute
#
dash
class-attribute
#
notation
class-attribute
#
operators
class-attribute
#
apply(function, argument)
#
cardinality(inner)
#
cases(arms)
#
document(blocks, *, standalone)
#
Source code in src/math_spec/typesetting/format.py
equations(lines, *, numbered)
#
Source code in src/math_spec/typesetting/format.py
escape(prose)
#
fraction(numerator, denominator)
#
Source code in src/math_spec/typesetting/format.py
glossary(title, entries)
#
Source code in src/math_spec/typesetting/format.py
greek(name)
#
italic(name)
#
joined(parts, operator)
#
math(expression)
#
mono(text)
#
note(text)
#
parenthesise(inner)
#
Source code in src/math_spec/typesetting/format.py
prose(text)
#
quoted(label)
#
script(letter)
#
section(title, body)
#
Source code in src/math_spec/typesetting/format.py
subscript(base, indices)
#
Source code in src/math_spec/typesetting/format.py
summation(domain, body)
#
Source code in src/math_spec/typesetting/format.py
superscript(base, tail)
#
Source code in src/math_spec/typesetting/format.py
Glossary(title, entries)
dataclass
#
Line(label, left, right, condition='')
dataclass
#
One typeset line of the model, split where a format may align it.
left and right are the two sides of a relation — right carries
the relation symbol, so a format aligns on the boundary between them
without having to parse anything back out.
aligned_rows(lines, fmt, *, gap)
#
One alignment row per line — label, left, right, condition — gap around the relation, trailing empty cells stripped.