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
🐍 Python API - Stable programmatic interface for integration into pipelines and scripts
🛡️ Type-safe - Full mypy strict mode
✅ Well tested - Comprehensive test coverage
📦 Installation
We recommend using for the fastest installation experience, but and are fully supported alternatives. provides faster dependency resolution and better reproducibility, while and work with any standard Python environment.
uv
pip
pipx
uv
pip
pipx
Recommended: Using uv (Fastest)
# Install ascii-guard
uv tool install ascii-guard
Note: If uv is not installed, you may install it with: curl -LsSf https://astral.sh/uv/install.sh | sh
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
🐍 Python API
ascii-guard provides a stable Python API for programmatic use. Perfect for integrating into documentation pipelines, CI/CD scripts, or custom tooling.
from ascii_guard import lint_file, fix_file, detect_boxes
# Lint a file for issues
result = lint_file("README.md")
if result.has_errors:
print(f"Found {len(result.errors)} alignment errors")
for error in result.errors:
print(f" Line {error.line + 1}: {error.message}")
# Auto-fix alignment issues
result = fix_file("README.md", dry_run=True) # Preview first
print(f"Would fix {result.boxes_fixed} boxes")
# Detect boxes without validation
boxes = detect_boxes("docs/guide.md")
print(f"Found {len(boxes)} ASCII art boxes")
Available functions:
lint_file() - Lint a file for ASCII art alignment issues
fix_file() - Fix alignment issues in a file
detect_boxes() - Detect ASCII art boxes without validation
validate_box() - Validate a single Box object
fix_box() - Fix a single Box object
Data models:Box, ValidationError, LintResult, FixResult
📖 Full API documentation: See API Reference for complete details, type signatures, and advanced examples.
🤝 Contributing
We welcome contributions! Here's how to get started:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Fork and clone the repository
git clone https://github.com/YOUR-USERNAME/ascii-guard.git
cd ascii-guard
# One-step setup (creates venv, installs deps, configures hooks)
./setup.sh
# Use uv run for commands
uv run pytest # Run tests
uv run ruff check . # Lint code
uv run mypy src/ # Type check
# Make your changes and submit a PR