mdcheck
A linter and validator for Markdown files that enforces the CommonMark specification.
Think cargo check, but for Markdown.
Features
- ✅ Validates CommonMark compliance
- ✅ Detects undefined link references
- ✅ Checks list and indentation consistency
- ✅ Enforces header level progression
- ✅ Detects bare URLs
- ✅ Skips validation inside code blocks
- ✅ Recursive directory scanning
- ✅ Multiple output formats (human-readable, JSON)
- ✅ Unclosed element detection
Installation
From crates.io
Build locally
Usage
Run mdcheck on Markdown files or directories.
Check specific files
Check all Markdown files in a directory
Recursively check all Markdown files
Output in JSON format
Strict mode (treat warnings as errors)
Ignore warnings
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success — no errors (and no warnings in strict mode) |
| 1 | Failure — errors found, or warnings in strict mode |
Example Output
document.md:
error 3: Undefined link reference '[missing]'
warning 7: Bare URL detected (consider using link syntax)
warning 12: Inconsistent indentation (prefer 2 or 4 spaces)
Summary: 1 error, 2 warnings in 1 file
Checks Performed
Errors
- Undefined link references
- Unclosed Markdown elements
- File read errors
Warnings
- Bare URLs without link syntax
- Inconsistent indentation (not 2 or 4 spaces)
- Inconsistent list indentation
- Header level jumps (e.g. from H1 to H3)
Command-Line Help
<PATHS>...
)
)
)
Configuration
Currently configured via command-line flags.
Future versions may support config files for custom rule sets.
Contributing
Pull requests are welcome!
Fork, tinker, and open an issue or PR if you’ve got ideas or improvements.
License
MIT