Mixed-language text reads better with a hair of space between scripts. Pangu inserts that space — at build time, at runtime, or via a CSS pseudo-element — wherever you want it.
Why
Typesetters have been doing this by hand for a century. We taught a regex to do it.
What’s inside
- A 30-line core function
- An Astro integration
- A Vite plugin
- Optional client-side fallback for dynamic content
The line that does the work
text.replace(/([一-龥])([A-Za-z0-9])/g, '$1 $2');
That’s it. The rest is testing, packaging, and prose.