Expand description
Deterministic hyphenation engine using Liang’s TeX algorithm.
Implements the standard TeX hyphenation pattern matching algorithm for discovering valid break points within words. The algorithm is deterministic: same patterns + same word → same break points, always.
§Architecture
Patterns → PatternTrie (compile once)
Word → wrap with delimiters → slide all substrings through trie
→ collect max levels at each inter-character position
→ odd levels = break allowed§Integration
Break points integrate with the penalty model from crate::wrap:
- Each
HyphenBreakPointmaps to acrate::wrap::BreakPenaltywithflagged = true. - The
crate::wrap::ParagraphObjectivehandles consecutive-hyphen demerits.
Structs§
- Hyphen
Break Point - A valid hyphenation break point within a word.
- Hyphenation
Dict - A hyphenation dictionary for a specific language.
- Hyphenation
Pattern - A compiled hyphenation pattern.
- Pattern
Trie - Trie-based pattern storage for O(n²) per-word lookup.
Constants§
- ENGLISH_
EXCEPTIONS_ MINI - Common English exception words with explicit hyphenation.
- ENGLISH_
PATTERNS_ MINI - A minimal set of English TeX hyphenation patterns.
Functions§
- break_
penalties - Map a sequence of hyphenation break points to penalties suitable for the Knuth-Plass line-breaking algorithm.
- compile_
pattern - Parse a TeX-format hyphenation pattern string into a compiled pattern.
- english_
dict_ mini - Create a minimal English hyphenation dictionary.