2026-04-10 16:24:58 +02:00
2026-04-10 16:24:58 +02:00
2026-04-10 15:24:42 +02:00
2026-04-10 15:24:42 +02:00
2026-04-10 16:24:58 +02:00
2026-04-10 15:24:42 +02:00
2026-04-10 15:24:42 +02:00

mdlink

mdlink is a CLI tool to recursively scan Markdown files and validate HTTP/HTTPS links.

Features

  • Scans .md files recursively in a directory (or a single .md file).
  • Extracts Markdown links ([text](url)) and naked URLs (https://...).
  • Ignores image links (![alt](url)).
  • Checks links with httpx and follows redirects automatically.
  • Ignores 200 OK in the report; shows non-200 and request errors.
  • Shows final resolved URL in output.
  • Asks interactively before rewriting redirected Markdown links.
  • Re-checks target URL before writing (must still return 200).
  • Rewrites links via Markdown AST editing (markdown-it-py), not string replacement.

Installation

python3 -m venv .venv
source .venv/bin/activate
pip install .

Usage

mdlink /path/to/docs

Scan current directory recursively:

mdlink .

Options

  • --timeout FLOAT
    Per-request timeout in seconds (default: 10.0).

Interactive Redirect Rewrite

Step 1: When a Markdown link redirects, mdlink prompts:

Replace old URL with final URL? [y/N]

Step 2: For http:// Markdown links without redirect, mdlink can test an https:// variant and prompt:

Replace HTTP URL with HTTPS variant? [y/N]

Only confirmed links are updated.

Test File And Script

This repository includes:

  • test.sh: Generates a sample Markdown test file.
  • test.md: A sample file with mixed link cases (200, redirect, 404/500, naked URLs, ignored image/non-http links).

Generate or overwrite test.md:

./test.sh

Generate to a custom file path:

./test.sh /tmp/my-test.md

Run the tool against the generated test file:

mdlink test.md

Help

mdlink --help
Description
Link-Check für Markdown
Readme 37 KiB
Languages
Python 94.7%
Shell 5.3%