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

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.1.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.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for markdown_macros_extension-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af170cad4942fcbd3c91d4348c972c353de7c93c96895d7718747361b7820537
MD5 eb65a3e086b6f09a8695b5d9864b8730
BLAKE2b-256 09bc846c78a605cb1f8e7b79ead6c41c32ebe4d6dc913eb1793f97972e01b2ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_macros_extension-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b37e29968b8620d1121ec98a2d526edb2601de6b0ca80031e249042f29b4eb2a
MD5 a1b1c0e326a9eb9af2c316f511a6196c
BLAKE2b-256 647f0aaa31e5477e20ba81f603b5d7ba61a7250c48e92d1b06f2594b3697551c

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