Skip to main content

Markdown Link Prefix

PyPI version Python 3.8+ License: MIT Deploy docs to GitHub Pages

Author: BarCar · Repository: github.com/barcar/markdown-link-prefix

A Python-Markdown extension that expands prefixed link shorthand into full URLs. Write [text](youtube:VIDEO_ID) or [KB](snkb:KB123); when rendered, they become normal links using URL templates you define in a YAML file or config. All prefixes come from link_prefixes.yaml (or prefixes_file) and/or the prefixes option—nothing is hard-coded. Works with Zensical, MkDocs, or any tool that uses Python-Markdown.

BuyMeACoffee

Features

  • Prefixed links: [text](prefix:id) → [text](https://.../id) via a URL template with {id}.
  • All from config or file: define prefixes in prefixes_file (YAML) and/or prefixes; if the file is missing or empty and no config is given, no prefixes are defined.
  • Optional link titles: [text](prefix:id "title") is supported.

Installation

pip install markdown-link-prefix

Requires: markdown>=3.4. For loading from a YAML file: pip install "markdown-link-prefix[yaml]" (PyYAML).

Quick example

import markdown
from markdown_link_prefix import LinkPrefixExtension

text = "[Watch](youtube:dQw4w9WgXcQ) and [KB](snkb:KB0012345)"
md = markdown.Markdown(extensions=[
    LinkPrefixExtension(prefixes_file="docs/link_prefixes.yaml", project_root=".")
])
html = md.convert(text)  # links expanded from the YAML templates

In Zensical or MkDocs, add link_prefix to your Markdown extensions and set prefixes_file (and optionally prefixes). See the documentation for configuration, usage, and examples.

Documentation

Online: Documentation (GitHub Pages).

To build the docs locally:

pip install -e ".[docs]"
zensical serve

(The Changelog page may 404 locally—it is generated from root CHANGELOG.md in CI only.)

License

MIT License. See LICENSE.

Metadata

Release files for markdown-link-prefix 0.1.1

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-prefix 0.1.1
File Size Uploaded Provenance Actions
markdown_link_prefix-0.1.1.tar.gz 7.3 kB Without provenance Details for markdown_link_prefix-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 13.6 kB

Security for markdown-link-prefix 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.1.1 This release

2 release files No 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