md_check

Crates.iomd_check
lib.rsmd_check
version0.1.1
created_at2025-06-23 18:38:27.495325+00
updated_at2025-06-24 12:55:48.566912+00
descriptionCheck markdown link validity.
homepage
repositoryhttps://github.com/EricLBuehler/md_check
max_upload_size
id1723258
size75,395
Eric Buehler (EricLBuehler)

documentation

README

md_check

A fast and reliable command-line tool for checking dead links in Markdown files. Written in Rust, md_check helps you maintain documentation by finding broken links, invalid URLs, and missing local file references.

Features

  • 🔍 Comprehensive Link Detection: Finds all links in Markdown files including:
    • HTTP/HTTPS URLs
    • Local file references (.md files)
    • Anchor links within documents
    • Image links
  • 🚀 Fast & Efficient: Built with Rust for optimal performance
  • 🎨 Colorized Output: Clear visual feedback with colored terminal output
  • ⏱️ Configurable Timeout: Set custom timeout for HTTP requests
  • 📊 Detailed Reporting: Shows line numbers and specific error messages
  • 🔗 Smart Anchor Validation: Validates internal document anchors

Installation

From crates.io (recommended)

Ensure you have Rust installed, then:

cargo install md_check

From Source

Ensure you have Rust installed, then:

git clone https://github.com/EricLBuehler/md_check.git
cd md_check
cargo build --release

The binary will be available at target/release/md_check.

Usage

Basic Usage

md_check README.md

Command Line Options

md_check [OPTIONS] <FILE>

Arguments

  • <FILE> - Path to the markdown file to check

Options

  • -t, --timeout <TIMEOUT> - Timeout for each request in seconds (default: 30)
  • -v, --verbose - Enable verbose output to see each link as it's checked
  • -h, --help - Print help information
  • -V, --version - Print version information

Examples

Check a file with verbose output:

md_check --verbose docs/guide.md

Check with a custom timeout:

md_check --timeout 10 README.md

How It Works

  1. Link Extraction: Parses the Markdown file using pulldown-cmark to extract all links
  2. Link Validation:
    • HTTP/HTTPS links: Sends HEAD requests to verify the link is accessible
    • Local .md files: Checks if the file exists on the filesystem
    • Anchor links: Validates that the anchor exists in the target document
  3. Reporting: Provides a summary of all dead or invalid links with line numbers

Output Examples

Success

Info: Checking links in: README.md

Info: Found 15 links to check

Success: All links are valid! ✓

Errors Found

Info: Checking links in: docs/guide.md

Info: Found 20 links to check

Error: Found 3 dead or invalid links:

  ✗ Line 45: https://example.com/broken-link
    └─ Error: HTTP 404
  
  ✗ Line 67: ./missing-file.md
    └─ Error: File not found: ./missing-file.md
  
  ⚠ Line 89: ./other-file.md#missing-anchor
    └─ Invalid: Anchor 'missing-anchor' not found in other-file.md

Exit Codes

  • 0 - All links are valid
  • 1 - One or more dead links found or error occurred

Development

Running Tests

cargo test

Building Debug Version

cargo build

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

Built with these excellent Rust crates:

Commit count: 0

cargo fmt