Metadata-Version: 2.4
Name: markdown-macros-extension
Version: 0.5.0
Summary: Python-Markdown extension: MkDocs-Macros–style Jinja2 templating (variables, macros, filters) with YAML front matter for Zensical and MkDocs
Author: BarCar
License-Expression: MIT
Project-URL: Documentation, https://barcar.github.io/markdown-macros/
Project-URL: Repository, https://github.com/barcar/markdown-macros
Keywords: markdown,frontmatter,yaml,zensical,mkdocs,macros
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: Markup
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: markdown>=3.4
Requires-Dist: pyyaml>=6.0
Requires-Dist: jinja2>=3.0
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Provides-Extra: docs
Requires-Dist: zensical; extra == "docs"
Dynamic: license-file

# Markdown Macros

[![PyPI version](https://img.shields.io/pypi/v/markdown-macros-extension.svg)](https://pypi.org/project/markdown-macros-extension/)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Deploy docs to GitHub Pages](https://github.com/barcar/markdown-macros/actions/workflows/pages.yml/badge.svg)](https://github.com/barcar/markdown-macros/actions/workflows/pages.yml)


**Author:** [BarCar](https://github.com/barcar) · **Repository:** [github.com/barcar/markdown-macros](https://github.com/barcar/markdown-macros)

A **Python-Markdown extension** that brings [MkDocs Macros](https://mkdocs-macros-plugin.readthedocs.io/)–style **Jinja2 templating** to any Markdown pipeline: variables (config + YAML front matter), **macros**, and **filters**. Works with [Zensical](https://zensical.org), MkDocs, or plain Python—without the MkDocs plugin.

[![BuyMeACoffee](https://raw.githubusercontent.com/barcar/buymeacoffee-badges/main/bmc-donate-white.svg)](https://buymeacoffee.com/barcar)

## 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

```bash
pip install markdown-macros-extension
```

Requires: `markdown>=3.4`, `pyyaml>=6.0`, `jinja2>=3.0`.

## Quick example

```python
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](https://barcar.github.io/markdown-macros/) for configuration, usage, and the full API.

**Compatibility:** API-aligned with the [MkDocs Macros plugin](https://mkdocs-macros-plugin.readthedocs.io/) (variables, macros, filters, `define_env`); see [Compatibility](https://barcar.github.io/markdown-macros/compatibility/) in the docs.

## Documentation

**Online:** [Documentation](https://barcar.github.io/markdown-macros/) (GitHub Pages).

To build the docs locally:

```bash
pip install -e ".[docs]"
zensical serve
```

## License

MIT License. See [LICENSE](LICENSE).
