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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for markdown_macros_extension-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e855ab3e6216e65477e8b3961f19502ef9afb82e606e9371c9e6fb2b0923cce1
MD5 cc3f1ba1ba1a0763d77bebf05ebfa87f
BLAKE2b-256 b92446f42e9f84bdf315058a98cd3d513ee6bce2d7955ff2dfa9b8f48d2eda95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_macros_extension-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1de18eaf1e0a93244335d821979774c58e40bf2e20275db5d6ced36279cd4fc
MD5 5fd71be3b769fc861e66a599e3fcbad7
BLAKE2b-256 c700197f4b1541c9c0bfc9943185b3967e3a80c8056b02e73d6010a087562e33

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