How polytypo Guarantees Typography Rules Compose Safely Across Nine Passes
Developer Lior built polytypo, a typography-normalization engine, to apply nine text-rewriting rules in a strictly defined order to ensure consistent, locale-aware text formatting. A subtle bug discovered during development revealed that running the same pipeline twice could produce asymmetric spacing, since individually correct rules — one stripping spaces before full stops, another promoting hyphens to en dashes — break each other's output when composed. To prevent such issues, polytypo uses a single source-of-truth JSON file to fix rule execution order, explicitly avoiding language quirks like Go's randomized map iteration. The engine has been integrated into the site's build process via a git pre-commit hook, with a CI gate written but not yet run in production. polytypo is published across five runtimes — JavaScript, Python, Go, Ruby, and PHP — each required to conform to the same versioned spec, including all nine rules, even those that are off by default.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in