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).
Shaper::shape— text → written-unit sequence (Mvs/Nirugu/Zwjappear verbatim)Shaper::same_shape— do two encodings render identically?Shaper::normalize/Shaper::normalize_text— canonical, FVS-pinned UnicodeShaper::normalize_written_units/Shaper::normalize_positioned_written_units— encode written units directlyShaper::trace— per-rule condition transitions, for debugging and the golden fixtures
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§
- Condition
Change - One condition change recorded by
Shaper::trace. - Positioned
Written Unit - One record of
Shaper::normalize_positioned_written_units: a written unit with its authoritative HUD inventory position (ControlforMvs/Nirugu). - Rule
Transition - The changes one rule made, in
Shaper::trace. - Shape
Trace - 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 (positionIsol, conditionNone, no written units). - Shaper
- The UTN #57 shaping engine (and, for MNG, the canonical normalizer) for one locale.
- Token
Detail - 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
Shaperuses. - Position
- Joining-topology position of a letter within its chain.
- Unit
Position - Position of a written unit in the authoritative HUD inventory, as accepted by
Shaper::normalize_positioned_written_units. - Written
Unit - A written unit: an opaque glyph-form identifier produced by shaping (see
docs/data-format.md). The structural tokensMvs,NiruguandZwjare members too: they appear verbatim inShaper::shapeoutput, 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
ca Mongolian letter (not FVS / MVS / nirugu / punctuation / digit)? - is_
mongolian_ word_ char - Does
cparticipate 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).