Python-Markdown extension: MkDocs-Macros–style Jinja2 templating (variables, macros, filters) with YAML front matter for Zensical and MkDocs
Project description
Markdown Macros
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.
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.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markdown_macros_extension-0.2.0.tar.gz.
File metadata
- Download URL: markdown_macros_extension-0.2.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2664a72b2e424878ae35755ed17735f9e5cbf8cf20e44039e2f1a32c4df865a9
|
|
| MD5 |
9c1513eaa905cf5f87e479e243a15a9d
|
|
| BLAKE2b-256 |
ab2e720e16cc1e0373baf3fd81999fb2c01b5246e73736ca9a9b660699064799
|
File details
Details for the file markdown_macros_extension-0.2.0-py3-none-any.whl.
File metadata
- Download URL: markdown_macros_extension-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5a064b1d030504307f17e8d634eb063243a04614e0ba19b274f37793c17ab91
|
|
| MD5 |
1ccef92e29d5cb030de919c0566b0053
|
|
| BLAKE2b-256 |
a4a234baa5a2bc11ec76c9b8b2ae2872d6b79c8a47bebf7f7702c7d0b0a816ab
|