| Crates.io | markdownlint-rs |
| lib.rs | markdownlint-rs |
| version | 0.2.8 |
| created_at | 2025-11-17 17:11:57.62924+00 |
| updated_at | 2026-01-21 07:11:45.481751+00 |
| description | A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files |
| homepage | |
| repository | https://github.com/swanysimon/markdownlint-rs |
| max_upload_size | |
| id | 1937238 |
| size | 465,752 |
A fast, flexible, configuration-based command-line interface for linting Markdown files, written in Rust.
Project Status: Active development. Compatible with markdownlint-cli2 configuration and rule behavior.
--fix.gitignore files by defaultmarkdownlint-rs aims for full compatibility with markdownlint-cli2:
Download the latest release for your platform from the releases page:
Linux (x86_64):
curl -LO https://github.com/swanysimon/markdownlint-rs/releases/latest/download/mdlint-linux-x86_64.tar.gz
tar xzf mdlint-linux-x86_64.tar.gz
sudo mv mdlint /usr/local/bin/
Linux (ARM64):
curl -LO https://github.com/swanysimon/markdownlint-rs/releases/latest/download/mdlint-linux-aarch64.tar.gz
tar xzf mdlint-linux-aarch64.tar.gz
sudo mv mdlint /usr/local/bin/
macOS (Intel):
curl -LO https://github.com/swanysimon/markdownlint-rs/releases/latest/download/mdlint-macos-x86_64.tar.gz
tar xzf mdlint-macos-x86_64.tar.gz
sudo mv mdlint /usr/local/bin/
macOS (Apple Silicon):
curl -LO https://github.com/swanysimon/markdownlint-rs/releases/latest/download/mdlint-macos-aarch64.tar.gz
tar xzf mdlint-macos-aarch64.tar.gz
sudo mv mdlint /usr/local/bin/
Windows:
Download mdlint-windows-x86_64.exe.zip from the releases page and extract it to a directory in your PATH.
Verify checksum (optional but recommended):
# Linux/macOS
sha256sum -c mdlint-*.sha256
# Windows (PowerShell)
$expected = (Get-Content mdlint-*.sha256).Split()[0]
$actual = (Get-FileHash mdlint.exe).Hash.ToLower()
if ($expected -eq $actual) { "OK" } else { "FAILED" }
cargo install markdownlint-rs
git clone https://github.com/swanysimon/markdownlint-rs.git
cd markdownlint-rs
cargo build --release
sudo cp target/release/mdlint /usr/local/bin/
Pull from GitHub Container Registry:
docker pull ghcr.io/swanysimon/markdownlint-rs:latest
Run on files in the current directory:
docker run --rm -v "$PWD:/workspace" ghcr.io/swanysimon/markdownlint-rs:latest
Run with auto-fix:
docker run --rm -v "$PWD:/workspace" ghcr.io/swanysimon/markdownlint-rs:latest --fix
Run with custom config:
docker run --rm -v "$PWD:/workspace" ghcr.io/swanysimon/markdownlint-rs:latest --config .markdownlint.json
Available tags:
latest - Latest stable release1.x.x - Specific version (e.g., 1.0.0)1.x - Latest patch version in minor release (e.g., 1.0)1 - Latest minor version in major releaseThe Docker image supports both linux/amd64 and linux/arm64 platforms.
Lint all Markdown files in the current directory:
mdlint
Lint specific files or directories:
mdlint README.md docs/
Lint with auto-fix:
mdlint --fix
mdlint [OPTIONS] [PATTERNS]...
Arguments:
[PATTERNS]... Glob patterns for files to lint (defaults to current directory)
Options:
--config <PATH> Path to configuration file
--fix Apply fixes to files
--no-globs Ignore globs from configuration
--format <FORMAT> Output format: default or json [default: default]
--no-color Disable color output
-h, --help Print help
-V, --version Print version
Lint with custom config file:
mdlint --config .markdownlint.json
Output as JSON:
mdlint --format json
Lint specific glob patterns:
mdlint "**/*.md" "!node_modules/**"
Fix issues automatically:
mdlint --fix docs/
Disable color output (for CI):
mdlint --no-color
markdownlint-rs discovers configuration files automatically by searching up from the current directory:
The tool searches for these files in order (first found wins per directory level):
.markdownlint-cli2.jsonc.markdownlint-cli2.yaml.markdownlint-cli2.json.markdownlint.jsonc.markdownlint.json.markdownlint.yamlpackage.json (in markdownlint-cli2 key)JSONC/JSON (.markdownlint-cli2.jsonc):
{
// Rule configuration
"config": {
"default": true, // Enable all rules by default
"MD013": false, // Disable line length rule
"MD003": { "style": "atx" } // Configure heading style
},
// File selection
"globs": ["**/*.md"],
"ignores": ["node_modules/**", "dist/**"],
// Options
"fix": false,
"gitignore": true,
"noInlineConfig": false
}
YAML (.markdownlint-cli2.yaml):
config:
default: true
MD013: false
MD003:
style: atx
globs:
- "**/*.md"
ignores:
- "node_modules/**"
- "dist/**"
fix: false
gitignore: true
Configurations are discovered by walking up the directory tree. When multiple configs are found, they are merged with the following precedence (highest to lowest):
--config, --fix, etc.).markdownlint-cli2.jsonc in current dir)Arrays (like globs and ignores) are extended, not replaced.
Each rule can be configured in multiple ways:
{
"config": {
"MD001": true, // Enable rule
"MD002": false, // Disable rule
"MD003": { "style": "atx" }, // Configure with options
"MD007": { "indent": 4 }, // Set specific parameters
"default": true // Enable all rules by default
}
}
See the markdownlint rules documentation for details on each rule and its configuration options.
Use exit codes in CI/CD pipelines:
mdlint || exit 1 # Fail build on linting errors
markdownlint-rs implements 54 rules compatible with markdownlint:
| Rule | Description | Fixable |
|---|---|---|
| MD001 | Heading levels should only increment by one level at a time | ❌ |
| MD003 | Heading style | ❌ |
| MD004 | Unordered list style | ❌ |
| MD005 | Inconsistent indentation for list items at the same level | ❌ |
| MD007 | Unordered list indentation | ❌ |
| MD009 | Trailing spaces | ✅ |
| MD010 | Hard tabs | ✅ |
| MD011 | Reversed link syntax | ❌ |
| MD012 | Multiple consecutive blank lines | ✅ |
| MD013 | Line length | ❌ |
| MD018 | No space after hash on atx style heading | ✅ |
| MD019 | Multiple spaces after hash on atx style heading | ✅ |
| MD022 | Headings should be surrounded by blank lines | ✅ |
| MD023 | Headings must start at the beginning of the line | ✅ |
| MD025 | Multiple top-level headings in the same document | ❌ |
| ... | See markdownlint rules for full list | ... |
While markdownlint-rs aims for compatibility, there are some intentional differences:
Contributions are welcome! See CONTRIBUTING.md for:
MIT License - see LICENSE for details.