From 0d7c9b3153687fe9a8da2d676e581b07de767e2e Mon Sep 17 00:00:00 2001 From: Bastian Venthur Date: Tue, 4 Nov 2025 09:06:47 +0100 Subject: [PATCH] Added footnotes --- CHANGELOG.md | 1 + README.md | 1 + blag/markdown.py | 1 + blag/static/style.css | 7 +++++++ tests/test_markdown.py | 14 ++++++++++++++ 5 files changed, 24 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64277e7..7221504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Added Python 3.14 compatibility * Removed requirements.txt and requirements-dev.txt +* Added footnotes extension for markdown ## [2.3.3] -- 2025-04-27 diff --git a/README.md b/README.md index 3b723f8..4e86c4b 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ blag is named after [the blag of the webcomic xkcd][blagxkcd]. * Theming support using [Jinja2][] templates * Generation of Atom feeds for blog content * Fenced code blocks and syntax highlighting using [Pygments][] +* Markdown footnotes * Integrated devserver * Available on [PyPI][] diff --git a/blag/markdown.py b/blag/markdown.py index ee4c573..7b26375 100644 --- a/blag/markdown.py +++ b/blag/markdown.py @@ -34,6 +34,7 @@ def markdown_factory() -> Markdown: "fenced_code", "codehilite", "smarty", + "footnotes", MarkdownLinkExtension(), ], output_format="html", diff --git a/blag/static/style.css b/blag/static/style.css index 8e5c332..9c269a0 100644 --- a/blag/static/style.css +++ b/blag/static/style.css @@ -151,3 +151,10 @@ header h2 { display: inline; font-size: 1.2rem; } + +hr { + border: none; + border-top: 1px solid var(--foreground-dim); + opacity: 0.3; + margin: 2rem 0; +} diff --git a/tests/test_markdown.py b/tests/test_markdown.py index 5e393d2..3612319 100644 --- a/tests/test_markdown.py +++ b/tests/test_markdown.py @@ -111,3 +111,17 @@ this --- is -- a test ... assert "mdash" not in html assert "ndash" not in html assert "hellip" not in html + + +def test_footnotes() -> None: + """Test footnote extension.""" + md = markdown_factory() + md1 = """ +this is a footnote[^1] + +[^1]: this is the footnotetext +""" + html, meta = convert_markdown(md, md1) + assert "
" in html + assert "
    " in html + assert "footnotetext" in html