Skip to main content

A zero-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.

License Python CI codecov Code style: ruff Type checked: mypy PRs Welcome


๐ŸŽฏ 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

  • ๐Ÿš€ ZERO runtime dependencies - Pure Python stdlib only
  • ๐Ÿ’พ Tiny footprint - Lightweight and fast
  • ๐Ÿ”’ No supply chain risk - No third-party code
  • โšก Quick startup - No import overhead
  • ๐Ÿ“ฆ Simple installation - One command, no dependency hell
  • ๐Ÿ›ก๏ธ 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 zero system pollution:

# Development dependencies are isolated in .venv/
# Runtime has ZERO dependencies (pure stdlib)
# All tools (ruff, mypy, pytest) are dev-only

# Verify zero runtime dependencies
python -c "import ascii_guard; print('Success - no imports failed')"

๐Ÿ“‹ Validation Rules

ascii-guard checks for:

  1. Vertical alignment - All โ”‚ characters in a column align
  2. Horizontal alignment - All โ”€ characters connect properly
  3. Corner correctness - Corner characters match adjacent lines
  4. Width consistency - Top, middle, and bottom borders match
  5. Content fit - Content stays within box borders

๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

  1. Fork and clone the repository
  2. Run ./setup-venv.sh to set up your environment
  3. Make your changes
  4. Run tests and linters: pre-commit run --all-files
  5. Submit a pull request

Code Style

  • Zero dependencies - No external runtime dependencies allowed
  • 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


๐Ÿ™ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ascii_guard-0.1.0.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ascii_guard-0.1.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file ascii_guard-0.1.0.tar.gz.

File metadata

  • Download URL: ascii_guard-0.1.0.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ascii_guard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 884fbea5627ab8cb50b34ac2a14504c1e6daa3ccddf2990cba1ae72b7dd29df8
MD5 1e469f7edc98373d60dc1f1f24559769
BLAKE2b-256 218e1c702453dc5d81930d952b38f42755f1fb7855d847e979dfe6b5657a12e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ascii_guard-0.1.0.tar.gz:

Publisher: release.yml on fxstein/ascii-guard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ascii_guard-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ascii_guard-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ascii_guard-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9c728c2d143b6e9b09c621e10c52eaa96ed0ad457561fa47533e211e1fd13cb
MD5 fa1237f2c336634c2aeb230495792b33
BLAKE2b-256 558876873dea0e6511928763c09d1fd2ac4f4785dfb73683ef95e289b662684b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ascii_guard-0.1.0-py3-none-any.whl:

Publisher: release.yml on fxstein/ascii-guard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page