Documentation
¶
Overview ¶
Package mathdata provides immutable, generated mathematical metadata shared by Untie's TeX and Typst frontends and by the font layer.
The package deliberately exposes lookups rather than its backing slices. Callers receive value copies and can therefore neither reorder generated data nor mutate process-global tables.
All data is checked in. Upstream KaTeX, Typst, and Typlet sources are needed only for an explicit maintainer regeneration, never at build or runtime.
Index ¶
- func ApplyVariant(r rune, v AlphaVariant) (string, bool)
- func ApplyVariantString(s string, v AlphaVariant) (string, bool)
- func LookupNegatedRelation(base string) (string, bool)
- func VariantRune(r rune, v AlphaVariant) (styled rune, selector rune, ok bool)
- type AlphaVariant
- type Class
- type Operator
- type TeXFont
- type TeXGroup
- type TeXSymbol
- type TeXSymbolKind
- type TypstShorthand
- type TypstSymbol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyVariant ¶
func ApplyVariant(r rune, v AlphaVariant) (string, bool)
ApplyVariant styles r with v.
It returns the original rune and true for VariantPlain. If no direct mapping exists, it returns the original rune and false so callers can apply their documented fallback policy.
func ApplyVariantString ¶
func ApplyVariantString(s string, v AlphaVariant) (string, bool)
ApplyVariantString maps every rune in s independently.
Unmapped runes are preserved unchanged. The returned bool reports whether every rune had a direct mapping.
func LookupNegatedRelation ¶
LookupNegatedRelation returns the precomposed Unicode relation whose visual semantics are the base relation plus a negation stroke.
func VariantRune ¶
func VariantRune(r rune, v AlphaVariant) (styled rune, selector rune, ok bool)
VariantRune returns the Unicode mathematical alphanumeric form of r in v.
A non-empty selector identifies a variation selector that must accompany the returned rune. ok is false when Unicode has no direct mapping for r in v; in that case the first return value is empty.
Types ¶
type AlphaVariant ¶
type AlphaVariant uint8
AlphaVariant is a Unicode mathematical alphanumeric style.
Calligraphic and Script are distinct because fonts use variation selectors to distinguish chancery from roundhand forms. Bold variants are distinct for the same reason.
const ( VariantPlain AlphaVariant = iota VariantBold VariantItalic VariantBoldItalic VariantDoubleStruck VariantScript VariantBoldScript VariantFraktur VariantBoldFraktur VariantSansSerif VariantSansSerifBold VariantSansSerifItalic VariantSansSerifBoldItalic VariantMonospace VariantCalligraphic VariantBoldCalligraphic )
func (AlphaVariant) String ¶
func (v AlphaVariant) String() string
String returns the Typst-facing name of v.
type Class ¶
type Class uint8
Class is a Unicode math character class as used by OpenType MATH layout.
Numeric values are stable and intentionally match the order of Typst's unicode_math_class::MathClass enum.
func DefaultClass ¶
DefaultClass returns the math class Typst uses by default for r.
It is UnicodeClass with Typst 0.15.1's documented overrides applied. Frontend code that needs raw Unicode data should call UnicodeClass instead.
func UnicodeClass ¶
UnicodeClass returns the Unicode MathClass.txt class for r.
The lookup table is generated from unicode-math-class 0.1.0 as transcribed by the pinned Typlet checkout. Characters absent from MathClass.txt return false.
type Operator ¶
Operator describes a named, no-argument math operator.
Name includes the leading backslash for TeX operators and has no prefix for Typst. Text is the upright operator text for named text operators; it is empty for TeX symbol operators whose glyph is resolved through the font.
func LookupTeXOperator ¶
LookupTeXOperator returns metadata for a TeX operator such as \sin or \sum.
func LookupTypstOperator ¶
LookupTypstOperator returns metadata for a Typst operator such as sin or lim.
type TeXGroup ¶
type TeXGroup uint8
TeXGroup is KaTeX's parser-level symbol group.
It is intentionally finer than Class: mathord and textord both usually use ClassNormal or ClassAlphabetic, but frontends need the original distinction when choosing an alphabet.
type TeXSymbol ¶
type TeXSymbol struct {
Command string
// Text is portable Unicode text. It is never a KaTeX private-use code point.
// It is empty for commands with no standalone portable scalar, such as
// internal composition primitives and zero-width spacing controls.
Text string
Class Class
Group TeXGroup
Font TeXFont
AcceptUnicode bool
Kind TeXSymbolKind
// SourceGlyph is the original KaTeX private-use code point for traceability.
// It is source metadata, not renderable text; zero means no private-use code.
SourceGlyph rune
}
TeXSymbol is metadata for a no-argument TeX symbol command.
func LookupTeXSymbol ¶
LookupTeXSymbol returns metadata for a TeX command such as \alpha.
type TeXSymbolKind ¶
type TeXSymbolKind uint8
TeXSymbolKind distinguishes public syntax from KaTeX implementation details.
const ( // TeXSymbolPublic is a command that may appear in user TeX. TeXSymbolPublic TeXSymbolKind = iota // TeXSymbolInternal is a KaTeX implementation command, conventionally // prefixed with \@. It must not be offered as user-facing syntax. TeXSymbolInternal )
func (TeXSymbolKind) String ¶
func (k TeXSymbolKind) String() string
String returns a stable name for the symbol kind.
type TypstShorthand ¶
TypstShorthand is one Typst math-mode source shorthand.
func LookupTypstShorthand ¶
func LookupTypstShorthand(syntax string) (TypstShorthand, bool)
LookupTypstShorthand returns the symbol value for an exact shorthand.
func MatchTypstShorthandPrefix ¶
func MatchTypstShorthandPrefix(text string) (TypstShorthand, bool)
MatchTypstShorthandPrefix returns the longest shorthand matching the start of text.
The table is small and deliberately kept separate from lexical precedence. Callers decide whether the returned candidate is legal at their lexer state.
type TypstSymbol ¶
TypstSymbol is one addressable variant of a Typst sym-module symbol.
func LookupTypstSymbol ¶
func LookupTypstSymbol(path string) (TypstSymbol, bool)
LookupTypstSymbol returns a Typst symbol by its full path, such as arrow.r.
func LookupTypstSymbolVariant ¶
func LookupTypstSymbolVariant(name, modifier string) (TypstSymbol, bool)
LookupTypstSymbolVariant returns name when modifier is empty, or the dot-separated path name.modifier otherwise.