finds.dev← search

// the find

vinta/pangu.js

★ 4,780 · TypeScript · MIT · updated Jun 2026

Opinionated paranoid text spacing in JavaScript

pangu.js automatically inserts spaces between CJK characters and latin/numeric text in HTML pages and plain text. It's the JavaScript port of a multi-language family of tools solving a real typographic problem for East Asian web content. The Chrome extension is the primary use case; the npm package lets you run it server-side or in build pipelines.

The regex-based spacing logic is battle-tested across thousands of edge cases, with a test suite covering every symbol category individually — that fixture directory tells you this thing has been poked at hard. MutationObserver integration in autoSpacingPage() means it handles dynamically injected content without manual re-triggering. Ships proper ES module and CJS builds with type declarations, so it drops cleanly into modern toolchains. Active maintenance (last push June 2026) on a project this old is a good sign.

The explicit warning not to use it on Markdown is a real limitation — if your content pipeline mixes markup and plain text, you need to handle that boundary yourself or you will corrupt your output. No support for other CJK spacing standards beyond the Pangu rules, so Japanese or Korean edge cases that deviate from the Chinese-centric assumptions are your problem. The Chrome extension ships compiled JS in the repo (dist/ checked in), which means the source of truth for the extension build is ambiguous. Test coverage for browser behavior requires Playwright and headless browsers, which is a heavier dev setup than the problem warrants.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →