AsciiDoc Linter is a command-line tool that checks your AsciiDoc files for common issues and style violations. It helps maintain consistent documentation by enforcing rules for heading structure, formatting, whitespace, and image usage.
Note
|
This project is part of docToolchain (https://doctoolchain.org), a collection of documentation tools and best practices. |
Rule ID | Description | Severity |
---|---|---|
HEAD001 |
Check for proper heading hierarchy (no skipping levels) |
ERROR |
HEAD002 |
Verify heading format (spacing and capitalization) |
ERROR/WARNING |
HEAD003 |
Detect multiple top-level headers |
ERROR |
BLOCK001 |
Check for unterminated blocks (listing, example, sidebar, etc.) |
ERROR |
BLOCK002 |
Verify proper spacing around blocks |
WARNING |
WS001 |
Check whitespace usage (blank lines, list markers, tabs) |
WARNING |
IMG001 |
Verify image attributes and file references |
WARNING/ERROR |
# Clone the repository
git clone https://github.com/docToolchain/asciidoc-linter.git
# Navigate to the project directory
cd asciidoc-linter
# Install the package
pip install .
# Check a single file
asciidoc-lint document.adoc
# Check multiple files
asciidoc-lint doc1.adoc doc2.adoc
# Check with specific output format
asciidoc-lint --format json document.adoc
The linter supports three output formats:
-
console
(default): Human-readable output -
json
: Machine-readable JSON format -
html
: HTML report format
Checking file: document.adoc
ERROR: Heading level skipped: found h3 after h1 (line 15)
=== Advanced Topics
WARNING: Heading should start with uppercase letter (line 23)
== introduction to concepts
ERROR: Unterminated listing block starting (line 45)
----
WARNING: Block should be preceded by a blank line (line 67)
----
ERROR: Multiple top-level headings found (line 30)
First heading at line 1: 'Document Title'
WARNING: Missing alt text for image: diagram.png (line 80)
image::diagram.png[]
# Run all tests
python run_tests.py
# Run specific test file
python -m unittest tests/rules/test_heading_rules.py
asciidoc-linter/
├── asciidoc_linter/
│ ├── __init__.py
│ ├── cli.py
│ ├── rules/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── heading_rules.py
│ │ ├── block_rules.py
│ │ ├── whitespace_rules.py
│ │ └── image_rules.py
│ ├── parser.py
│ └── reporter.py
├── tests/
│ └── rules/
│ ├── test_heading_rules.py
│ ├── test_block_rules.py
│ ├── test_whitespace_rules.py
│ └── test_image_rules.py
├── docs/
│ ├── requirements.adoc
│ └── block_rules.adoc
├── README.adoc
└── run_tests.py
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
-
Part of the docToolchain project (https://doctoolchain.org)
-
Inspired by various linting tools and the need for better AsciiDoc quality control
-
Thanks to the AsciiDoc community for their excellent documentation and tools
-
Phase 1 (Current)
-
✅ Basic heading rules
-
✅ Block structure rules
-
✅ Whitespace rules
-
✅ Image validation
-
⏳ Configuration system
-
-
Phase 2
-
🔲 Table validation
-
🔲 Link checking
-
🔲 Format rules
-
-
Phase 3
-
🔲 IDE integration
-
🔲 Git pre-commit hooks
-
🔲 Custom rule development
-
-
Project Homepage: https://github.com/docToolchain/asciidoc-linter
-
Issue Tracker: https://github.com/docToolchain/asciidoc-linter/issues
-
docToolchain Homepage: https://doctoolchain.org