Python-Markdown extension to support bootstrap alerts
Project description
Boostrap alerts extension for Python-Markdown
This extension adds bootstrap alerts support to Python-Markdown.
Installation
Install from PyPI
$ python -m pip install mdx_alerts
Install locally using poetry
Use poetry build
to build the extensions.
Then, you can install it via pip:
$ python -m pip install dist/mdx_alerts-1.0.0-py3-none-any.whl
Usage
There are two different ways to use the extensions.
Either, by using its identifier mdx_alerts
:
>>> import markdown
>>> md = markdown.Markdown(extensions=["mdx_alerts"])
... or by supplying an instance of AlertExtension
:
>>> import markdown
>>> from mdx_alerts import AlertExtension
>>> md = markdown.Markdown(extensions=[AlertExtension()])
Markdown pattern and customization
The pattern starts with two colons follows by the alert level, e.g. info. Everything after the newline character is counted towards the alert message/body until on an empty line the two colons appear again.
:: info
This is the body.
Even multi-line is possible.
::
The above snippet results in:
<div class="alert alert-info" role="alert">
<h4 class="alert-heading"><strong>Info</strong></h4>
<p>This is the body.</p>
<p>Even multi-line is possible.</p>
</div>
Additionally, you can overwrite the default heading by supplying an alternative via the heading=
attribute after the alert level:
:: info heading="Alternative Heading"
This is the body.
::
... which results in:
<div class="alert alert-info" role="alert">
<h4 class="alert-heading"><strong>Alternative Heading</strong></h4>
<p>This is the body.</p>
</div>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mdx_alerts-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7cef00382319bd7e3d93259d7b4d4e3dffcf67956ab94c1561671de2ecc09c4 |
|
MD5 | 5a9ecd251721665340e1542917c4c0ab |
|
BLAKE2b-256 | 647c626d900d7d01d20015f22493c54c49ef7778b0bd28f0472857082044baea |