Skip to main content

Markdown Link Resolver

A zero-dependency Python micro-tool to resolve relative links and image paths in Markdown files to absolute URLs. Perfect for web scraping, RAG pipelines, and LLM data preparation.

Installation

pip install markdown-link-resolver

(For local development: pip install -e .)

Basic Usage

from markdown_link_resolver import resolve_markdown_links

base_url = "[https://example.com/blog/](https://example.com/blog/)"
dirty_markdown = "Check out our [about us](../about) page or our ![logo](images/logo.png)."

clean_markdown = resolve_markdown_links(dirty_markdown, base_url)
print(clean_markdown)
# Output: Check out our [about us](https://example.com/about) page or our ![logo](https://example.com/blog/images/logo.png).

Advanced: Base64 Images & Authentication (v0.2.0)

If you are passing scraped data to Multimodal LLMs (like GPT-4o or Claude 3.5), you can automatically inline images as base64 strings.

If the images are behind a login wall, you can pass custom HTTP headers (like a Bearer token or session cookie) to authenticate the download.

auth_headers = {
    "Authorization": "Bearer YOUR_API_TOKEN"
}

md_with_images = "Look at this chart: ![Chart](/assets/private-chart.png)"

prepared_md = resolve_markdown_links(
    md_with_images, 
    base_url="[https://secure.example.com/](https://secure.example.com/)", 
    inline_images=True, 
    headers=auth_headers
)

# Output: Look at this chart: ![Chart](data:image/png;base64,iVBORw0KGgo...)

Graceful Fallbacks: If an image download times out (5s) or returns a 404, the script gracefully falls back to the absolute URL without crashing your pipeline.

Metadata

Release files for markdown-link-resolver 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markdown-link-resolver 0.2.0
File Size Uploaded Provenance Actions
markdown_link_resolver-0.2.0.tar.gz 5.6 kB With provenance Details for markdown_link_resolver-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for markdown-link-resolver 0.2.0
File Interpreter ABI Platform Actions
markdown_link_resolver-0.2.0-py3-none-any.whl Python 3 none any Details for markdown_link_resolver-0.2.0-py3-none-any.whl

Total release size: 10.4 kB

Security for markdown-link-resolver 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page