Skip to main content

A variables extension for Markdown

Project description

mdx_variables
=============

|variables-ci-badge|

.. |variables-ci-badge| image:: https://travis-ci.org/CTPUG/mdx_variables.png?branch=master
:alt: Travis CI build status
:scale: 100%
:target: https://travis-ci.org/CTPUG/mdx_variables

A Markdown extension to add support for variables.

Licensed under the `ISC License`_.

.. _ISC License: https://github.com/CTPUG/mdx_variables/blob/master/LICENSE


Requirements
============

The mdx_variables plugin requires only the base `markdown`_ library.

.. _markdown: http://pythonhosted.org/Markdown/


Installation
============

Install with ``pip install mdx_variables``.


Documentation
=============

Allows inserting variables into Markdown.

The following Markdown example:

.. code:: markdown

This paragraph contains ${chickens} chickens.

This paragraph contains no chickens but ${foxes} foxes.

Are there ninjas here? ${ninjas}.

Might result in:

.. code:: markdown

This paragraph contains 5 chickens.

This paragraph contains no chickens but 3 foxes.

Are there ninjas here? ninjas not found.


Python usage:

.. code:: python

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 function
``f(name) -> value`` to call when no matching variable is found.

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

mdx_variables-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for mdx_variables-0.1.0.tar.gz
Algorithm Hash digest
SHA256 20c6ccb1fe14c5a48dcb72a31b81627687d695e9918d1e9b03675ff4676c584a
MD5 08a049cdda62359ef2e6e6a8db001f17
BLAKE2b-256 d1c45e90d7583a20e0930a504dd5b3542e0a138d976c07ed3f8898c46251ca21

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page