A variables extension for Markdown
Project description
mdx_variables
A Markdown extension to add support for variables.
Licensed under the ISC License.
Requirements
The mdx_variables plugin requires only the base markdown library.
Installation
Install with pip install mdx_variables.
Documentation
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 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
File details
Details for the file mdx_variables-0.1.1.tar.gz
.
File metadata
- Download URL: mdx_variables-0.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5b2d214a692d7fc1b2bbc9e9598882fcda96e89e10bea3464a9acb7e2f7599c |
|
MD5 | 376d745a5526596a5f6d0f087fa78aac |
|
BLAKE2b-256 | 27d924293b4818b3580bfd07c5e78e39cf8e5f817668f78de25f338fbf1a9043 |