Skip to content

mdx_steroids.md_mako»

The mdx_steroids.md_mako feeds Markdown through the Mako templating system.

Installation»

pip install --user --upgrade git+https://github.com/twardoch/markdown-steroids.git

Docs»

Options»

  mdx_steroids.md_mako:
    include_base    : '.'        # Default location from which to evaluate relative paths for the `<%include file="..."/>` statement.
    include_encoding: 'utf-8'    # Encoding of the files used by the `<%include file="..."/>` statement.
    include_auto    : 'head.md'  # Path to Mako file to be automatically included at the beginning.
    python_block    : 'head.py'  # Path to Python file to be automatically included at the beginning as a module block. Useful for global imports and functions.
    meta:                        # Dict of args passed to `mako.Template().render()`. Can be overriden through Markdown YAML metadata.
      author        : 'John Doe' # Can be referred inside the Markdown via `${author}`
      status        : 'devel'    # Can be referred inside the Markdown via `${status}`

Example»

This assumes that the meta or mdx_steroids.meta_yaml extension is enabled,
so parsing metadata at the beginning of the file works.

Input Markdown»

---
author: John Doe
---
<%!
import datetime
def today():
    now = datetime.datetime.now()
    return now.strftime('%Y-%m-%d')
%>

${author} has last edited this on ${today()}.

% for number in ['one', 'two', 'three']:
* ${number}
% endfor

Output HTML»

John Doe has last edited this on 2017-08-17.

  • one
  • two
  • three
<p>John Doe has last edited this on 2017-08-17.</p>
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>

Copyright © 2017 Adam Twardoch adam+github@twardoch.com
License: BSD 3-clause