Easily link to IETF documentation from within MarkDown
Project description
Referencing IETF sources
links to RFCs with a simple syntax --
[RFC-9110]
and[RFC-2045-section-5.1]
links to HTTP headers regardless of current RFC that defines it --[HTTP-Accept]
I wrote this simple extension when I was converting my ietfparse project from sphinx
to mkdocs. It's documentation suite contains a lot of references to RFCs and HTTP
headers. Sphinx supports referencing RFCs using :rfc:
natively. The
sphinxcontrib-httpdomain package adds support for HTTP headers and status codes
using :http:
. I wanted to bring this to mkdocs so that I didn't need to
continuously add local references to RFCs.
Usage
This is the simple part. This extension recognizes two reference style link patterns and converts them to hyperlinks.
Markdown Text | Generated HTML |
---|---|
[RFC-9110] |
<a href="https://www.rfc-editor.org/rfc/rfc9110">RFC-9110</a> |
[RFC-9110-name-accept] |
<a href="https://www.rfc-editor.org/rfc/rfc9110#name-accept">Accept</a> |
[HTTP-Accept] |
<a href="https://www.rfc-editor.org/rfc/rfc9110#name-accept">Accept</a> |
I haven't created a syntax that lets you control the link text yet. I may in the future but this met my immediate need.
Configuration
Simply add the library to your environment using your chosen package management mechanism. I use [hatch], so my pyproject.toml contains:
[tool.hatch.envs.default]
dependencies = [ "ietflinks", "mkdocs" ]
Then add ietflinks
as a Markdown extension in your mkdocs.yml.
markdown_extensions:
- ietflinks
That's it! A surprising bonus is that you don't have to think about the finer points of referencing IETF documents like which URL template to use for RFCs -- if you know what I am talking about, then you will appreciate this feature. It also takes care of knowing which RFC currently defines which HTTP header.
Customization
Since the Internet is always changing, you can add support for new HTTP headers or even override what I chose by default directly in your configuration file.
markdown_extension:
- ietflinks:
http_headers:
overrides:
content-md5: "https://www.rfc-editor.org/rfc/rfc2616.html#section-14.15"
You can also change the URL template if you find a reason to. It defaults to
https://www.rfc-editor.org/rfc/rfc{rfc}
. The {rfc}
parameter is replaced by the
RFC number.
markdown_extensions:
- ietflinks:
link_template: "https://tools.ietf.org/html/rfc{rfc}"
You can also disable processing of either syntax by setting the process
property to false
.
markdown_extensions:
- ietflinks:
rfc:
process: false
When a reference style is disabled, the reference is replaced by its text without the brackets.
So [RFC-9110]
would be replaced by <span>RFC-9110</span>
. You can enable pure passthrough
functionality by setting process
to null
.
A json schema for the configuration is available at the root of the repository.
https://raw.githubusercontent.com/dave-shawley/pymdown-ietf/refs/heads/main/config-schema.json
Project details
Release history Release notifications | RSS feed
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 pymdown_ietflinks-0.0.0.tar.gz
.
File metadata
- Download URL: pymdown_ietflinks-0.0.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74b2c53f219dc400cdac407398d741c2df9b9234a31f4c3243d56f9068036208 |
|
MD5 | 2802f9b883bae046c7b73e4cb5286505 |
|
BLAKE2b-256 | f6668eda983aef6787b87237f2df6e58d644d167102d304237c85ef588172e6c |
Provenance
The following attestation bundles were made for pymdown_ietflinks-0.0.0.tar.gz
:
Publisher:
python-publish.yml
on dave-shawley/pymdown-ietf
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pymdown_ietflinks-0.0.0.tar.gz
- Subject digest:
74b2c53f219dc400cdac407398d741c2df9b9234a31f4c3243d56f9068036208
- Sigstore transparency entry: 147948328
- Sigstore integration time:
- Predicate type:
File details
Details for the file pymdown_ietflinks-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: pymdown_ietflinks-0.0.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45b2f6e8277c7c3fef28048d0c162b5e8bbac25a7f728e31faa8c2e785d42dcb |
|
MD5 | a829108866f0d86f1be22e6081a96578 |
|
BLAKE2b-256 | 9e5f895265950e498e95beaf2b390d022bb86eedc453efb630210a19977194df |
Provenance
The following attestation bundles were made for pymdown_ietflinks-0.0.0-py3-none-any.whl
:
Publisher:
python-publish.yml
on dave-shawley/pymdown-ietf
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pymdown_ietflinks-0.0.0-py3-none-any.whl
- Subject digest:
45b2f6e8277c7c3fef28048d0c162b5e8bbac25a7f728e31faa8c2e785d42dcb
- Sigstore transparency entry: 147948329
- Sigstore integration time:
- Predicate type: