import re def compress_whitespace(text: str) -> str: """ Collapse runs of spaces/tabs to a single space on each line, trim traili…
Project description
whitespace_normalizer
whitespace_normalizer is a Python package designed to clean and standardize whitespace within text. It collapses multiple spaces and tabs into single spaces on each line, trims trailing whitespace, and removes entirely blank lines.
Installation
To install whitespace_normalizer, use pip:
pip install whitespace_normalizer
Usage
Using whitespace_normalizer is straightforward. Import the normalize_whitespace function and pass your string to it.
from whitespace_normalizer import normalize_whitespace
text_with_messy_whitespace = """
This is a string with
extra spaces.
And some
trailing whitespace.
"""
cleaned_text = normalize_whitespace(text_with_messy_whitespace)
print(cleaned_text)
This will output:
This is a string with
extra spaces.
And some
trailing whitespace.
Features
- Collapses consecutive spaces and tabs into a single space per line.
- Removes trailing whitespace from each line.
- Eliminates empty lines from the text.
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
License
whitespace_normalizer is licensed under the MIT License.
Author
Eugene Evstafev
Repository
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whitespace_normalizer-2025.9.14911.tar.gz.
File metadata
- Download URL: whitespace_normalizer-2025.9.14911.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c315a498372ed4b02788f9ce4ee5da62bc326b54f37be9364bc0995354278bf
|
|
| MD5 |
a0866fae513794404447b474563eef61
|
|
| BLAKE2b-256 |
ed7af0ec88c28ebbce0cc1013d1bf805b3e53f4b80cc42ce621749fb49912b6a
|
File details
Details for the file whitespace_normalizer-2025.9.14911-py3-none-any.whl.
File metadata
- Download URL: whitespace_normalizer-2025.9.14911-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe279fb6436200885ba3cb1601dadd88ea2a0009964f7dfa932b44f09ec3a9f7
|
|
| MD5 |
627a2f7b7b4b26c50df492bbefd9984a
|
|
| BLAKE2b-256 |
3b92e5928389ff0fb109ecf6b7a24cd1864fcfe7caeac9e30d914ae2cfb972a0
|