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.2.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.2-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for markdown_macros_extension-0.3.2.tar.gz
Algorithm Hash digest
SHA256 dfd2ffcb36e9d4f21746642c1034aff60c555bd3fd1d023887c4cf9f984b122d
MD5 92eacfdcc6856736bad0a274da8409ea
BLAKE2b-256 4bbc6c2c6e57fc1be1be1296f024e2de2f6a37d03efdfe675b4b6bb46e73d078

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_macros_extension-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3ab2a93b9cff9d68f9f672b6b286a265b6303181addd089740e3720a9605f0fa
MD5 e7b91466891b168adca795d9867d7bc1
BLAKE2b-256 c807b220e97e0302b53cbd0394817783f3119e8a27d7ab959bc3bee8f740ff24

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