This is a lightweight and fast tool to help you keep your Markdown files free of broken links.
Project description
Markdown Dead Link Checker
This handy tool helps you maintain the integrity of your Markdown files by identifying broken links. It scans your files and detects:
Here's what it does:
- Missing webpages: Links that no longer exist on the internet.
- Incorrect file links: Links that point to the wrong file in your project.
- Non-existent fragments (anchors): Links to specific sections that don't exist, e.g.
README.md#no-fragment
.
Example of output for fail.md
File: tests/test_md_files/fail.md:3 • Link: https://github.com/AlexanderDokuchaev/FAILED • Error: 404: Not Found
File: tests/test_md_files/fail.md:4 • Link: https://not_exist_github.githubcom/ • Error: 500: Internal Server Error
File: tests/test_md_files/fail.md:8 • Link: /test/fail.md1 • Error: Path does not exist
File: tests/test_md_files/fail.md:9 • Link: fail.md1 • Error: Path does not exist
File: tests/test_md_files/fail.md:13 • Link: a.md#fail • Error: Not found fragment
❌ Found 5 dead links 🙀
[!NOTE] By defaults, only error codes like 404 (Not Found), 410 (Gone), and 500 (Internal Server Error), and links that don't exist are considered "dead links". Other error codes typically indicate temporary issues with the host server or unsupported links for the HEAD request type.
How to Use It
Option 1: GitHub Actions
Add Github Action config to .github/workflow/
jobs:
md-dead-link-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: AlexanderDokuchaev/md-dead-link-check@0.4
Option 2: Pre-Commit
Adding to your .pre-commit-config.yaml
to integrate in pre-commit tool
- repo: https://github.com/AlexanderDokuchaev/md-dead-link-check
rev: "0.4"
hooks:
- id: md-dead-link-check
Option 3: Install from pip
For direct use, install with pip and run:
pip install md-dead-link-check
md-dead-link-check
Performance
This tool utilizes asynchronous API calls and avoids downloading full web pages, enabling it to process thousands links in several seconds.
Proxy
This tool leverages your system's existing HTTP and HTTPS proxy configuration.
It achieves this by trusting the environment variables that your operating system utilizes to define proxy settings.
This functionality is enabled by the aiohttp.ClientSession(trust_env=True)
option.
For further technical details, you can refer to the
aiohttp documentation.
[!WARNING] Without proxy configuration in environment, link failures may not be reported. If your environment lacks proxy configuration (variables like
http_proxy
andhttps_proxy
), link retrieval attempts may time out without indicating a failure. To help diagnose this issue, use the--verbose
argument to log all processed links.
Configuration
This tool seamlessly integrates with your project's pyproject.toml
file for configuration.
To leverage a different file, invoke the --config
option during execution.
- timeout: Specifies the maximum time (in seconds) to wait for web link responses. Default:
5
seconds. - catch_response_codes: List of HTTP response codes to consider as failures.
If empty, all codes greater than 400 will be marked as failures. Default:
[404, 410, 500]
. - exclude_links: List of links to exclude from checks. Default:
[]
. - exclude_files: List of files to exclude from checks. Default:
[]
. - force_get_requests_for_links: List of links for which the tool will use
GET
requests during checks. Default:[]
. - check_web_links: Toggle web link checks on or off. Default:
true
. - validate_ssl: Toggles whether to validate SSL certificates when checking web links. Default:
true
.
[!TIP] Leverage wildcard patterns (fnmatch syntax) for
exclude_links
,exclude_files
andforce_get_requests_for_links
parameters.
[tool.md_dead_link_check]
timeout = 10
exclude_links = ["https://github.com/", "*localhost*"]
exclude_files = ["tests/test_md_files/fail.md", "tests/*"]
check_web_links = true
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file md_dead_link_check-0.4.tar.gz
.
File metadata
- Download URL: md_dead_link_check-0.4.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25bff2fb3794b66e96392945d363b42f12624630e36fcc8ca1c7280e86f06606 |
|
MD5 | 7efaac3795cb4b2cee3f6b43effa4424 |
|
BLAKE2b-256 | e94a8f0aee2fccc50fd2a4d7dd059bac72961ffb2a22b69eee25f34541f12c8a |
File details
Details for the file md_dead_link_check-0.4-py3-none-any.whl
.
File metadata
- Download URL: md_dead_link_check-0.4-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b85979e5015cd8d1615fc8b0084c33ccfc3c9ce1cf73ca2a71a832c23a63c19 |
|
MD5 | 3347d93ee0b16753f6392964ac992f4e |
|
BLAKE2b-256 | 4144f057e752a264778365a2a20050023866818cb895298a7a4016f8c762cb5a |