| Crates.io | mdbook-lint |
| lib.rs | mdbook-lint |
| version | 0.13.7 |
| created_at | 2025-08-04 01:37:48.328569+00 |
| updated_at | 2026-01-25 05:59:51.083584+00 |
| description | A fast markdown linter and preprocessor for mdBook |
| homepage | |
| repository | https://github.com/joshrotenberg/mdbook-lint |
| max_upload_size | |
| id | 1780231 |
| size | 567,649 |
A fast, configurable linter designed for mdBook projects. Works as both an mdBook preprocessor and standalone CLI tool.
Documentation | Getting Started
mdBook is a command-line tool for creating books from Markdown files. It's widely used in the Rust ecosystem for documentation, including The Rust Programming Language book, and is popular for technical documentation projects of all kinds. mdBook renders Markdown into a clean, searchable HTML book format with navigation, search, and syntax highlighting.
mdbook-lint helps ensure your mdBook documentation maintains consistent quality by catching common issues before they reach readers.
brew tap joshrotenberg/brew
brew install mdbook-lint
cargo install mdbook-lint
By default, this includes all rule sets (standard, mdBook, and content rules). To install without specific rule sets:
# Without content rules (CONTENT001-011)
cargo install mdbook-lint --no-default-features --features standard,mdbook,lsp
# Only standard markdown rules
cargo install mdbook-lint --no-default-features --features standard,lsp
Download the latest release for your platform from GitHub Releases:
mdbook-lint-linux-x86_64mdbook-lint-linux-x86_64-musl (static binary, no dependencies)mdbook-lint-windows-x86_64.exemdbook-lint-macos-x86_64mdbook-lint-macos-aarch64Extract and add to your PATH, or use with GitHub Actions (see CI Integration).
Verify the installation:
mdbook-lint --version
Add to your book.toml:
[preprocessor.lint]
Then run mdbook build as usual. The linter will automatically check all your markdown files and report issues during the build process.
# Lint files
mdbook-lint lint README.md src/*.md
# Auto-fix violations (using the fix subcommand)
mdbook-lint fix src/*.md
# Preview what would be fixed
mdbook-lint fix --dry-run src/*.md
# Alternative: use lint with --fix flag
mdbook-lint lint --fix src/*.md
# Show available rules
mdbook-lint rules
Output uses cargo-style formatting with colors:
error[MD001]: Expected heading level 2 but got level 3
--> src/chapter.md:15:1
|
15 | ### Skipped heading level
| ^^^ heading-increment
Create a .mdbook-lint.toml file (also supports YAML/JSON):
# Disable rules that don't fit your project
disabled-rules = ["MD013", "MD033"]
# Configure specific rules
[MD007]
indent = 4
[MD009]
br_spaces = 2 # Allow 2 trailing spaces for line breaks
[MD003]
style = "atx" # Use # style headings
Generate a configuration file with all options documented:
mdbook-lint init --include-all
Configuration examples:
Run mdbook-lint rules --detailed to see all available rules.
name: Lint Documentation
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download mdbook-lint
run: |
curl -sSL https://github.com/joshrotenberg/mdbook-lint/releases/latest/download/mdbook-lint-linux-x86_64 -o mdbook-lint
chmod +x mdbook-lint
- name: Lint markdown files
run: ./mdbook-lint lint --fail-on-warnings docs/
mdbook-lint supports mdBook versions 0.4.x and 0.5.x. The tool automatically detects and handles differences in mdBook's JSON protocol between versions, so it works seamlessly regardless of which mdBook version you have installed.
For detailed compatibility information, see the Compatibility Guide.
Contributions are welcome! See our Contributing Guide for complete information.
mdbook-lint builds on the excellent work of:
We aim to be compatible with markdownlint's rule definitions while adding mdBook-specific functionality.
MIT OR Apache-2.0