Skip to main content

Crate mongol_norm

Crate mongol_norm 

Source
Expand description

§mongol-norm

Shape-aware normalizer for Traditional Mongolian (Hudum) script — the pure-Rust twin of the mongol-norm Python package that lives in the same repository.

Traditional Mongolian in Unicode has a fundamental problem: the same visible word can be encoded in many different code-point sequences (letters share glyphs, FVS selectors create equivalent spellings, joiners and MVS suffixes collapse more letters together). This crate implements a lightweight shaping engine — the UTN #57 v4 Mongolian-specific phase, driven only by the rule data of UTN #57 / mongfontbuilder, no font needed — and, on top of it, a canonical normalizer: within the bundled table’s domain, shape(x) == shape(y) implies normalize(x) == normalize(y), and shape(normalize(x)) == shape(x).

The crate has no dependencies and builds for wasm32-unknown-unknown. Its data tables are generated from the repository’s JSON by scripts/gen_rust_tables.py; every value-producing operation is byte-identical to the Python package of the same version. Design: https://github.com/Satsrag/mongol-norm/blob/main/docs/superpowers/specs/2026-09-01-rust-core-design.md.

Structs§

ConditionChange
One condition change recorded by Shaper::trace.
PositionedWrittenUnit
One record of Shaper::normalize_positioned_written_units: a written unit with its authoritative HUD inventory position (Control for Mvs / Nirugu).
RuleTransition
The changes one rule made, in Shaper::trace.
ShapeTrace
A per-rule trace of the shaping pipeline — the verifier for tests/golden/mng-phase-trace-v1.json. Every vector covers all tokens, structural ones included (position Isol, condition None, no written units).
Shaper
The UTN #57 shaping engine (and, for MNG, the canonical normalizer) for one locale.
TokenDetail
Per-token breakdown returned by Shaper::shape_detailed.

Enums§

Alias
A letter alias (phonemic short name, locale-relative); as_str() is the data-file name (a, oe, k2, …).
Condition
A shaping condition assigned by the rule pipeline; as_str() is the data-file name (chachlag_onset, …).
Error
Everything that can go wrong in this crate.
Fvs
A free variation selector (U+180B FVS1, U+180C FVS2, U+180D FVS3, U+180F FVS4).
Locale
A script locale: which data tables and shaping rules a Shaper uses.
Position
Joining-topology position of a letter within its chain.
UnitPosition
Position of a written unit in the authoritative HUD inventory, as accepted by Shaper::normalize_positioned_written_units.
WrittenUnit
A written unit: an opaque glyph-form identifier produced by shaping (see docs/data-format.md). The structural tokens Mvs, Nirugu and Zwj are members too: they appear verbatim in Shaper::shape output, exactly as the Python implementation emits them.

Constants§

MAX_POSITIONED_RECORDS
The positioned API accepts at most this many records (Python parity).

Functions§

is_mongolian_letter
Is c a Mongolian letter (not FVS / MVS / nirugu / punctuation / digit)?
is_mongolian_word_char
Does c participate in a Mongolian word run: a letter, an FVS, MVS, NNBSP, nirugu or ZWJ?
version
Crate version (the Cargo package version; lockstep with the Python package version).