- Port pangu.js
v10.4.0plus unreleasedmasterchanges up to8cd3a97d- Add spaces around
-,*,=, and&between CJK and an opening bracket:CJK-(A)becomesCJK - (A) - Add spaces around
-between brackets when a hyphen on the same line touches CJK:CJK-CJK[A]-(A)becomesCJK - CJK [A] - (A) - Keep bracket globs like
*[0-9].logintact - Keep
mo店+attached as a name suffix - Convert only a lone, tight middle dot to
・; keep runs like••••and middle dots with spaces around them
- Add spaces around
- Include
LICENSEin the wheel and the sdist, andCHANGELOG.mdin the sdist
- Implement Paranoid Text Spacing Algorithm v10 (ported from pangu.js
v10.1.1)- Never add spaces around
/next to CJK, except in file paths like/src/index.ts - Keep everything inside
http://andhttps://URLs untouched +between a word and CJK is a separator now, not a suffix:A+CJKbecomesA + CJK-between CJK and digits is a separator now, not a minus sign- Keep superscripts like
²,™, and®attached to the text on their left - Add spaces between CJK and Letterlike Symbols like
℃and№, and after©before digits
- Never add spaces around
- Support Python 3.8+
- Rename
spacing_text()tospace_text()andspacing_file()tospace_file() - CLI
-hshows the version at the start of the help text
- Implement Paranoid Text Spacing Algorithm v9 (ported from pangu.js
v9.1.0) - Support Python 3.11+
- Fully type-annotated (
py.typed) - Add a method:
pangu.has_proper_spacing() - Add a command-line tool:
pangu-py(an alias of the originalpangu, to avoid a name collision) - Add a CLI option:
-c/--check, which exits 0 if the text has proper spacing, 1 if not - Add an
encodingparameter tospacing_file(), which now reads files as UTF-8 by default - Remove
pangu.spacing(), usepangu.spacing_text()
Port of the pangu.js v9 text-spacing engine — same algorithm, same behavior, parity-locked by a 1:1 port of the pangu.js test suite.
Breaking changes:
- Half-width punctuation is no longer converted to full-width. The only conversions left: a colon in direct CJK contact right before parentheses becomes
:, and middle dots (·•‧) normalize to・. There is no flag to restore the old behavior pangu.spacing()is removed; usepangu.spacing_text()- Output is no longer stripped of leading/trailing whitespace
spacing_file()reads files as UTF-8 by default (new keyword-onlyencodingparameter) instead of the locale encoding- The CLI reads stdin only when no argument is given; an explicit argument wins over piped stdin, and an explicit
-argument always means stdin - CLI usage errors exit 2 (argparse convention)
- Requires Python >= 3.11
New:
- HTML tag protection (attribute values still spaced), tag mentions, backtick protection, compound words, file paths, per-line slash/pipe/plus readings, affix readings
pangu.has_proper_spacing(text)- CLI
-c/--check: exit 0 if the text has proper spacing, 1 if not (corrected text on stderr)
Internal:
- Packaging moved to
pyproject.toml+uv_build;src/pangu/package layout replaces the single-file module - The engine (
pangu._core) deliberately mirrors pangu.jssrc/shared/index.tsso upstream releases port as a mechanical diff (seedocs/adr/0001)
- Implement Paranoid Text Spacing Algorithm v4
- Support Python 3.7
- Drop Python 2.7 support
- Support Python 3.6
- Add a method:
pangu.spacing_file() - Add a command-line tool:
pangu
- Support Python 3.5
- Refactoring
- Rename
text_spacing()tospacing_text()
- Add an alias to
spacing():text_spacing() - Fix unicode issue in Python 2.x
- Fix setup.py
- Implement Paranoid Text Spacing Algorithm v2
- Synchronize version number with pangu.js
- Hello World