A minimal-dependency Python linter for detecting and fixing misaligned ASCII art boxes in documentation
Project description
ascii-guard
Zero-dependency Python linter for detecting and fixing misaligned ASCII art boxes in documentation.
๐ฏ Why ascii-guard?
AI-generated ASCII flowcharts and diagrams often have subtle formatting errors where box borders are misaligned by 1-2 characters. This breaks visual integrity and makes documentation harder to read.
ascii-guard automatically detects and fixes these alignment issues, ensuring your ASCII art looks perfect.
โจ Key Features
- ๐ Minimal dependencies - Zero for Python 3.11+, one tiny dep for Python 3.10 (
tomli) - ๐พ Tiny footprint - Lightweight and fast
- ๐ Minimal supply chain risk - Pure stdlib on 3.11+
- โก Quick startup - No import overhead
- ๐ฆ Simple installation - One command, automatic dependency handling
- ๐ก๏ธ Type-safe - Full mypy strict mode
- โ Well tested - Comprehensive test coverage
๐ฆ Installation
For Users (AI Agents)
pip install ascii-guard
That's it! No other dependencies needed.
For Developers
# Clone repository
git clone https://github.com/fxstein/ascii-guard.git
cd ascii-guard
# Set up development environment (creates venv, installs dev deps)
./setup-venv.sh
# Activate virtual environment
source .venv/bin/activate
# Install pre-commit hooks
pre-commit install
๐ Quick Start
Check files for ASCII art issues
ascii-guard lint README.md
ascii-guard lint docs/**/*.md
Auto-fix alignment issues
ascii-guard fix README.md
ascii-guard fix --dry-run docs/guide.md # Preview changes first
Example
Before (misaligned):
โโโโโโโโโโโโโโโโโโโโโโโ
โ Box Content โ
โโโโโโโโโโโโโโโโโโโโโโ โ Missing one character!
After (fixed):
โโโโโโโโโโโโโโโโโโโโโโโ
โ Box Content โ
โโโโโโโโโโโโโโโโโโโโโโโ โ Perfect alignment โ
๐จ Supported Box-Drawing Characters
ascii-guard supports Unicode box-drawing characters:
| Type | Characters | Description |
|---|---|---|
| Horizontal | โ (U+2500) |
Horizontal line |
| Vertical | โ (U+2502) |
Vertical line |
| Corners | โ โ โ โ |
Standard corners |
| T-junctions | โ โค โฌ โด |
Connection points |
| Cross | โผ |
Four-way intersection |
| Heavy lines | โ โ โ โ โ โ |
Bold variants |
| Double lines | โ โ โ โ โ โ |
Double-line variants |
๐ ๏ธ Development
Project Structure
ascii-guard/
โโโ src/ascii_guard/ # Source code (ZERO dependencies)
โ โโโ __init__.py # Package initialization
โ โโโ cli.py # CLI interface (argparse only)
โ โโโ core.py # Linting logic (stdlib only)
โโโ tests/ # Test suite (pytest)
โโโ docs/ # Documentation
โโโ pyproject.toml # Project configuration
Running Tests
# Run all tests with coverage
pytest
# Run specific test file
pytest tests/test_cli.py
# Run with verbose output
pytest -v
# Fast tests only (pre-commit)
pytest -m "not slow"
Linting and Type Checking
# Run all pre-commit hooks
pre-commit run --all-files
# Run linter only
ruff check .
# Run formatter
ruff format .
# Run type checker
mypy src/
Virtual Environment Isolation
ascii-guard uses strict virtual environment isolation to ensure minimal system pollution:
# Development dependencies are isolated in .venv/
# Runtime has minimal dependencies:
# - Python 3.11+: Zero dependencies (uses stdlib tomllib)
# - Python 3.10: One dependency (tomli for TOML config)
# All tools (ruff, mypy, pytest) are dev-only
# Verify minimal runtime dependencies
python -c "import ascii_guard; print('Success - no imports failed')"
๐ Validation Rules
ascii-guard checks for:
- Vertical alignment - All
โcharacters in a column align - Horizontal alignment - All
โcharacters connect properly - Corner correctness - Corner characters match adjacent lines
- Width consistency - Top, middle, and bottom borders match
- Content fit - Content stays within box borders
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Setup
- Fork and clone the repository
- Run
./setup-venv.shto set up your environment - Make your changes
- Run tests and linters:
pre-commit run --all-files - Submit a pull request
Code Style
- Minimal dependencies - Only essential runtime dependencies (tomli for Python 3.10)
- Type-safe - All code must pass
mypy --strict - Tested - Maintain high test coverage
- Formatted - Code is auto-formatted with ruff
๐ License
Apache License 2.0 - see LICENSE for details.
Copyright 2025 Oliver Ratzesberger
๐ Links
- Repository: https://github.com/fxstein/ascii-guard
- Issues: https://github.com/fxstein/ascii-guard/issues
- PyPI: https://pypi.org/project/ascii-guard/ (coming soon)
- Documentation: docs/
๐ Acknowledgments
Inspired by the need for better ASCII art formatting in AI-generated documentation.
Built with โค๏ธ using only Python's standard library.
Note: This project is in active development (v0.1.0-alpha). The core linter functionality is being implemented. Contributions and feedback are welcome!
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 ascii_guard-1.2.0.tar.gz.
File metadata
- Download URL: ascii_guard-1.2.0.tar.gz
- Upload date:
- Size: 39.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9405c6e7a9161985c5d0538979c379037d30f111ddf2e8702076d22a2116baa0
|
|
| MD5 |
1e186eb4bd542e8fe09bc55628d0f99f
|
|
| BLAKE2b-256 |
a864c2d62e55affb74956552869ca3e9d09943ab3104905987e403357a2990a6
|
Provenance
The following attestation bundles were made for ascii_guard-1.2.0.tar.gz:
Publisher:
release.yml on fxstein/ascii-guard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ascii_guard-1.2.0.tar.gz -
Subject digest:
9405c6e7a9161985c5d0538979c379037d30f111ddf2e8702076d22a2116baa0 - Sigstore transparency entry: 705544352
- Sigstore integration time:
-
Permalink:
fxstein/ascii-guard@d0e5aae082223fcfa8491e313fe23969f694ddee -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/fxstein
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d0e5aae082223fcfa8491e313fe23969f694ddee -
Trigger Event:
push
-
Statement type:
File details
Details for the file ascii_guard-1.2.0-py3-none-any.whl.
File metadata
- Download URL: ascii_guard-1.2.0-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9181f181bc2a8a4d74400e5cf1f4e705cf8d046db971e07a982ac3856387c81
|
|
| MD5 |
848b0d293c4c51fadfb5cf8d271c5ce5
|
|
| BLAKE2b-256 |
f24cdc223482eaf27567bff53bd3d7dbf2fa20ba518f14fb5040148780772297
|
Provenance
The following attestation bundles were made for ascii_guard-1.2.0-py3-none-any.whl:
Publisher:
release.yml on fxstein/ascii-guard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ascii_guard-1.2.0-py3-none-any.whl -
Subject digest:
c9181f181bc2a8a4d74400e5cf1f4e705cf8d046db971e07a982ac3856387c81 - Sigstore transparency entry: 705544354
- Sigstore integration time:
-
Permalink:
fxstein/ascii-guard@d0e5aae082223fcfa8491e313fe23969f694ddee -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/fxstein
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d0e5aae082223fcfa8491e313fe23969f694ddee -
Trigger Event:
push
-
Statement type: