LinkMedic
Python package for checking internal links and resources in static web pages (.htm, .html) and external links to HTTP(S) or FTP servers. With optional dependencies, it can also test links in OpenDocument files (.odg, .odp, .ods, .odt), single OpenDocument XML files (.fodg, .fodp, .fods, .fodt), and user-defined XML files.
linkmedic starts a local test web server, requests the entry page from the server, and crawls all local pages. It checks all links within specific HTML/XML tags and reports any “dead” links found. If a link appears on multiple pages, it is tested only once. By default, links to external websites are ignored. If there is a .linkignore file in the website’s root, links matching the regular expressions listed in this file (one pattern per line; see user’s guide for examples) are also ignored during testing. After checking all the links, if any dead links are discovered, linkmedic exits with a non-zero status code.
For testing links in dynamic HTML content (e.g., using JavaScript template engines) or other document formats, you must first convert your pages (using a third-party tool) to static HTML and then run linkmedic on them.
Quick start
Install prerequisites
Depending on your operating system, you may have multiple options for installing the prerequisites. For a typical installation, you will need:
Python interpreter: linkmedic is only tested on officially supported Python versions.
A Python package installer: You can use pip for installing in a virtual environment or pipx for installing globally.
Install linkmedic
You can install linkmedic using your favorite Python package installer. For example, using pipx, you can install it from PyPI:
pipx install linkmedic
Run
To start a test web server with files at /var/www and crawl the pages and test all the links starting from /var/www/index.html, run:
linkmedic --root=/var/www/
Usage
Please refer to the user’s guide for details on the available options to install linkmedic and its usage.
Development and Maintenance
This repository is frequently used as a template for configuring Python development environments and CI/CD pipelines. It is intentionally designed with strict boundaries while prioritizing scalability and maintainability. Third-party dependencies are minimized to support this goal. The design goal is to have the option of running CI pipelines locally in an identical environment. PDM tracks exact Python dependency versions and hashes, which are detailed in its PEP 751 lockfile pylock.toml.
Code coverage is intentionally not 100%. While several testing approaches are demonstrated, the focus is on showcasing practical methods rather than achieving complete coverage.
Versioning is dynamic, based on Git tags. Project documentation is versioned, and its HTML output is automatically built and deployed here.
CI and release container recipes (Dockerfiles) are versioned, with OS packages sourced from the latest minor version of their base OS image at build time.
Refer to the developer’s guide for code development details, and maintainer’s guide for maintenance and release.
Security and Privacy Considerations
To respect user privacy, linkmedic does not send any data (e.g., telemetry, crash reports) to developers or third parties. However, when checking external links (with --check-external flag), it has to connect to other servers to verify the links, which exposes the testing machine’s external IP address. This also discloses the domain name of your links to your test environment’s DNS.
Reporting Issues
Before reporting an issue:
Check the Known Issues section in the user’s guide for solutions to frequent problems.
Run linkmedic with the --verbose flag for detailed error information.
If unresolved, report bugs and code-related issues here. If you have an MPCDF account, use the upstream repository instead. Please include in your report relevant information such as:
Your installation method
Python interpreter details: python -c "import sys; print(sys.version)"
Installed packages in the environment: pipx list or pip freeze
Minimal HTML pages and the command you used to run linkmedic for reproducing the issue
Verbose linkmedic logs
Security Issues
linkmedic implements defense-in-depth checks (path confinement, symlink resolution, scheme/host validation) to limit the blast radius if a file or network misconfiguration occurs within the container. However, bugs that exploits the container runtime itself should be reported to the container engine maintainers. Additionally, linkmedic doesn’t use or require pre-existing secrets, so its compromise has no impact outside the container.
History
The original idea for this project came from Dr. Klaus Reuter (MPCDF). Fruitful discussions with Dr. Sebastian Kehl (MPCDF) facilitated the packaging and release of this project.
Accompanying tools for linkmedic have been moved to a separate repositories:
linkmedkit: starting with version 0.7
ndx: starting with version 0.10
The laboratory module has been adapted from pre-commit-localupdate project.
License
Copyright 2021-2023 M. Farzalipour Tabriz, Max Planck Computing and Data Facility (MPCDF)
Copyright 2023-2026 M. Farzalipour Tabriz, Max Planck Institute for Physics (MPP)
All rights reserved.
This software is distributed under a combination of the 3-Clause BSD License and the GNU Lesser General Public License (LGPL). The license for each individual file is specified in its header. See the LICENSES directory for further details.
Metadata
Release files for linkmedic 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| linkmedic-0.10.0.tar.gz | 978.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linkmedic-0.10.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.0 MB
Release files / linkmedic-0.10.0.tar.gz
| Download URL | linkmedic-0.10.0.tar.gz |
|---|---|
| Size | 978.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c77c912a6d44d8a69f63307b82bc1ae79ef2106b52c9df8d39040844a46f0620
|
|
BLAKE2b-256 checksum How to use checksums |
986c9f73b7d98fe6b231a6650d81585a8b789e298485e51da55ab8cac617e5d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.27.0 CPython/3.12.3 Linux/6.8.0-138-generic
|
Release files / linkmedic-0.10.0-py3-none-any.whl
| Download URL | linkmedic-0.10.0-py3-none-any.whl |
|---|---|
| Size | 52.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b26e53e2a57ebda2c7596f14238a64a08a7fc3ae59e27a79695cfbb5783f392
|
|
BLAKE2b-256 checksum How to use checksums |
793fe3cdd31161e6dde597de87c4553ba4cd08f2fb882ec6ff963a6fc40ef9dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.27.0 CPython/3.12.3 Linux/6.8.0-138-generic
|