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.

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.

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.5.0.tar.gz (16.8 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.5.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for markdown_macros_extension-0.5.0.tar.gz
Algorithm Hash digest
SHA256 89bbf4ca992429b303bf3507dda8293d3b622ed073f399a3ced00d88873dd2bd
MD5 aedfe5290545cc5d30b9956fcafee95c
BLAKE2b-256 e6a79a30569bc2f29a2bedf4244124363cf94f731620a0d9371fadb0c88ac24c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_macros_extension-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5d2afd20dbda668cfd7b20470ff1a474ebe874760fa9447e35e297955996d66
MD5 0c9b65e6f5c31c30b1c8f0c28358ef3e
BLAKE2b-256 76078df1042546b1f8e295f8f1f662e3042469afa902532b0033c7fd55b62ece

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