pangu.py: Automated Paranoid Text Spacing for Enhanced Readability
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
pangu.py is a Python library designed for opinionated, "paranoid" text spacing. It automatically inserts whitespace between CJK (Chinese, Japanese, Korean) and half-width characters, such as alphabetical letters, numerical digits, and symbols. This tool significantly improves text readability by ensuring consistent and proper spacing.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
pangu.py is a Python library that implements "paranoid" text spacing to enhance readability. It automatically inserts whitespace between CJK (Chinese, Japanese, Korean) characters and half-width characters (alphabetical letters, numerical digits, and symbols). This opinionated approach ensures consistent and visually pleasing text formatting, making your content easier to read.
Installation
Installing pangu.py is straightforward using uv or pip:
$ uv add pangu
# or
$ pip install -U pangu
Examples
pangu.py can be used both within Python scripts and as a command-line tool.
In Python
import pangu
new_text = pangu.spacing_text("???????????????Monkey Patch????")
# new_text = "??????????????? Monkey Patch ????"
new_content = pangu.spacing_file("path/to/file.txt", encoding="utf-8")
# new_content = "? PM ??????????????? PM"
pangu.has_proper_spacing("?? Hadoop ??????????? Map/Reduce ?")
# True
In CLI
$ pangu-py "?????????????????????DevOps???????????????????????????????1.??2.???3.????"
????????????????????? DevOps??????????????????????????????? 1. ?? 2. ??? 3. ????
$ pangu-py -t "??????????Google?????Bing"
?????????? Google????? Bing
Why Use It
The primary benefit of pangu.py is the automatic improvement of text readability, especially for content mixing CJK and half-width characters. By consistently applying proper spacing, it eliminates common formatting inconsistencies and reduces visual clutter. This makes documents, articles, and user interfaces appear more professional and easier for readers to process, saving manual editing time.
Links
- GitHub Repository
- PyPI Project
- Other
panguimplementations:
Source repository
Open the original repository on GitHub.