Add to a web page to automatically space out Chinese text mixed with English words or digits as the page loads.
Use the Node.js API in a backend app or content pipeline to process mixed-script strings before saving or serving them.
Install the Chrome extension to improve readability on any website you browse without writing any code.
Process plain text files from the command line using the included CLI tool.
Pangu.js is a JavaScript library that automatically inserts a space between Chinese, Japanese, and Korean characters and Latin letters or numbers in text. When text mixes scripts such as Chinese alongside English words or digits, there is no automatic spacing between them, which many readers find harder to read. This library detects those boundaries and inserts a narrow space to improve readability. The project started as a Google Chrome browser extension that runs on web pages you visit, inserting spaces in real time as you browse. It is also available as a JavaScript library for developers who want to apply the same spacing in their own applications, either in a browser or in a Node.js environment. A command-line tool is included as well, so you can process plain text files directly from a terminal. For developers, the library exposes a few functions: one that processes a plain string and returns a spaced version, one that processes an HTML element in the page and updates its text in place, and one that watches the entire page for any DOM changes and automatically spaces new content as it appears. The library is designed for HTML pages and plain text, not for Markdown files, which the README notes explicitly. The same concept has been implemented by the community in Go, Python, Java, Ruby, Rust, Swift, and several other languages, all under the Pangu family name. The JavaScript version is published on npm and installable with a single command. It is a small, focused utility with no runtime dependencies and an MIT license.
← vinta on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.