Skip to main content

Markdown Macros

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

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

A Python-Markdown extension that brings MkDocs Macros–style Jinja2 templating to any Markdown pipeline: variables (config + YAML front matter), macros, and filters. Works with Zensical, MkDocs, or plain Python—without the MkDocs plugin.

BuyMeACoffee

Features

  • Variables from config, YAML front matter, or include_yaml
  • Macros and filters via define_env(env) in a Python module (same API as MkDocs Macros)
  • YAML front matter parsed and exposed as md.Meta / md.front_matter

Installation

pip install markdown-macros-extension

Requires: markdown>=3.4, pyyaml>=6.0, jinja2>=3.0.

Quick example

import markdown
from markdown_macros import MacrosExtension

text = """---
title: My Page
---

# {{ title }}

The answer is {{ 6 * 7 }}.
"""
md = markdown.Markdown(extensions=[MacrosExtension()])
html = md.convert(text)  # title and 42 rendered

In Zensical or MkDocs, add markdown_macros to your Markdown extensions and optionally set module_name, variables, include_yaml, etc. See the documentation for configuration, usage, and the full API.

Compatibility: API-aligned with the MkDocs Macros plugin (variables, macros, filters, define_env); see Compatibility in the docs.

Documentation

Online: Documentation (GitHub Pages).

To build the docs locally:

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

License

MIT License. See LICENSE.

Release files for markdown-macros-extension 0.5.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-macros-extension 0.5.0
File Size Uploaded
markdown_macros_extension-0.5.0.tar.gz 16.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markdown-macros-extension 0.5.0
File Interpreter ABI Platform
markdown_macros_extension-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.8 kB

Release files / markdown_macros_extension-0.5.0.tar.gz

Download URL markdown_macros_extension-0.5.0.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
89bbf4ca992429b303bf3507dda8293d3b622ed073f399a3ced00d88873dd2bd
BLAKE2b-256 checksum
How to use checksums
e6a79a30569bc2f29a2bedf4244124363cf94f731620a0d9371fadb0c88ac24c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / markdown_macros_extension-0.5.0-py3-none-any.whl

Download URL markdown_macros_extension-0.5.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5d2afd20dbda668cfd7b20470ff1a474ebe874760fa9447e35e297955996d66
BLAKE2b-256 checksum
How to use checksums
76078df1042546b1f8e295f8f1f662e3042469afa902532b0033c7fd55b62ece
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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