A Markdown extension to add support for variables.
Licensed under the ISC License.
The mdx_variables plugin requires only the base markdown library.
Install with pip install mdx_variables.
Allows inserting variables into Markdown.
The following Markdown example:
This paragraph contains ${chickens} chickens.
This paragraph contains no chickens but ${foxes} foxes.
Are there ninjas here? ${ninjas}.Might result in:
This paragraph contains 5 chickens.
This paragraph contains no chickens but 3 foxes.
Are there ninjas here? ninjas not found.Python usage:
md = markdown.Markdown(
    extensions=[
        'variables',
    ],
    extension_configs={
        'variables': {
            'vars': {
              'chickens': '5',
              'foxes': (lambda: 3),
              '__getattr__': (lambda name: "{} not found".format(name)),
            },
        }
    })Configuration options:
vars: A dictionary mapping variable names to variable values.If a value is a function, that function will be called without arguments and the result will be used as the variable value.
The special variable
__getattr__may specify a functionf(name) -> valueto call when no matching variable is found.