pymdvar - Python-Markdown Variable extension
Simple extension meant to be used to convert variables to their corresponding values. Works with environment variables too. This is really just built to be used with my other project pyssg, as I need it there but I figured it could be released as an extension.
It uses the ${variable} syntax. For example, given variable=value, the following text:
Foo ${variable} bar
Becomes:
<p>Foo value bar</p>
Install
pymdvar can be installed via pip:
python -m pip install pymdvar
Usage
The basic usage requires a dictionary with the variables to be passed to the VariableExtension options:
>>> import markdown
>>> from pymdvar import VariableExtension
>>> markdown.markdown('foo *${test}* bar', extensions=[VariableExtension(variables={'test': 'value'})])
'<p>foo <em>value</em> bar</p>'
if enable_env=True option is set, then it will read environment variables, too. Variables in variables take preference.
Syntax for the variables should only include the characters: a-z, A-Z, _ and 0-9; this limitation is set like this by personal preference, as the "variable" could be any string, could even include spaces and special chars. Variables not found are just replaced by an empty string.
Passing the extension as a string is supported:
>>> import markdown
>>> markdown.markdown('foo *${test}* bar', extensions=['pymdvar'], extension_configs={'pymdvar': {'variables': {'test': 'value'}}})
'<p>foo <em>value</em> bar</p>'
Options
Only supported options:
-
variables(defaultdict()):Dictionary containing key-value pairs for variable-values. Example
variables={'test': 'value', 'key': 'value'}
-
enable_env(defaultFalse):Enables environment variable reading.
Metadata
Release files for pymdvar 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pymdvar-1.0.3.tar.gz | 17.4 kB | Without provenance | Details for pymdvar-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pymdvar-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for pymdvar-1.0.3-py3-none-any.whl |
Total release size: 33.7 kB
Release files / pymdvar-1.0.3.tar.gz
| Download URL | pymdvar-1.0.3.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b0b0281a0e845a61d3bc4e47f0580f4813d47dcb5882c6d9e92be0d40067001
|
|
BLAKE2b-256 checksum How to use checksums |
e9ec34514841efffba81c043d7119d86e5301456558d2407a0622771401bea12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Release files / pymdvar-1.0.3-py3-none-any.whl
| Download URL | pymdvar-1.0.3-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f783fb26f2a7d1e366f29f9d484ba65c1bbb640c9c36b36f56340d2bdd6205c
|
|
BLAKE2b-256 checksum How to use checksums |
e3bb8aa05a1445e154ea2f4b3cdfe6dac2709722e6de2d2f93a56407d2381b56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.8
|
Security for pymdvar 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.