mathdata

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0, MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func LookupNegatedRelation(base string) (string, bool)

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.

const (
	ClassNormal Class = iota
	ClassAlphabetic
	ClassBinary
	ClassClosing
	ClassDiacritic
	ClassFence
	ClassGlyphPart
	ClassLarge
	ClassOpening
	ClassPunctuation
	ClassRelation
	ClassSpace
	ClassUnary
	ClassVary
	ClassSpecial
)

func DefaultClass

func DefaultClass(r rune) (Class, bool)

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

func UnicodeClass(r rune) (Class, bool)

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.

func (Class) String

func (c Class) String() string

String returns the Typst name of c.

type Operator

type Operator struct {
	Name   string
	Text   string
	Limits bool
	Symbol bool
}

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

func LookupTeXOperator(name string) (Operator, bool)

LookupTeXOperator returns metadata for a TeX operator such as \sin or \sum.

func LookupTypstOperator

func LookupTypstOperator(name string) (Operator, bool)

LookupTypstOperator returns metadata for a Typst operator such as sin or lim.

type TeXFont

type TeXFont uint8

TeXFont identifies the KaTeX symbol source font class.

const (
	TeXFontMain TeXFont = iota
	TeXFontAMS
)

func (TeXFont) String

func (f TeXFont) String() string

String returns the KaTeX source name of f.

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.

const (
	TeXGroupTextOrd TeXGroup = iota
	TeXGroupMathOrd
	TeXGroupOperator
	TeXGroupBinary
	TeXGroupRelation
	TeXGroupOpening
	TeXGroupClosing
	TeXGroupPunctuation
	TeXGroupInner
	TeXGroupAccent
	TeXGroupSpacing
)

func (TeXGroup) String

func (g TeXGroup) String() string

String returns the KaTeX group name.

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

func LookupTeXSymbol(command string) (TeXSymbol, bool)

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

type TypstShorthand struct {
	Syntax string
	Value  string
}

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

type TypstSymbol struct {
	Path        string
	Name        string
	Modifier    string
	Value       string
	Deprecation string
}

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.

Directories

Path Synopsis
Command gen generates Untie's checked-in math metadata.
Command gen generates Untie's checked-in math metadata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL