Skip to main content

Python-Markdown extension: MkDocs-Macros–style Jinja2 templating (variables, macros, filters) with YAML front matter for Zensical and MkDocs

Project description

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.

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

markdown_macros_extension-0.3.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdown_macros_extension-0.3.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file markdown_macros_extension-0.3.1.tar.gz.

File metadata

File hashes

Hashes for markdown_macros_extension-0.3.1.tar.gz
Algorithm Hash digest
SHA256 192a12f370f91a6973ee60dc08e44900d147950347d1404fea18cf75e59147dc
MD5 3141ae359620509d0dc84dbfcf5e20fa
BLAKE2b-256 2708fbe4c5755e0384d80e1e6b9dacbbf83881df20224297966a752dbd545972

See more details on using hashes here.

File details

Details for the file markdown_macros_extension-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for markdown_macros_extension-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 381aea755b9de6f3288f48c82cc88ed212c7ba1bd7970bbeb6007b2e65f76cf3
MD5 c520b118c34ea5f66a94bf6717514095
BLAKE2b-256 72610d0f9e02090a246e8cb6a4c4bddb3d210563d8cf008d829451ae79b598be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page