Skip to main content

Python-Markdown extension to support bootstrap alerts

Project description

Boostrap alerts extension for Python-Markdown

Tests Python 3.6

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdx_alerts-1.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

mdx_alerts-1.0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file mdx_alerts-1.0.1.tar.gz.

File metadata

  • Download URL: mdx_alerts-1.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.4.0-77-generic

File hashes

Hashes for mdx_alerts-1.0.1.tar.gz
Algorithm Hash digest
SHA256 791d2074b1a13d6637786fe64f0ce207a3a5d711fb0803902b40f872ba77faf1
MD5 15581783f3a75f7cc50353f8689e8728
BLAKE2b-256 b82a12d05e60d6e8d6869b0a693dc067dba245ff59907489b0fea6240234f866

See more details on using hashes here.

File details

Details for the file mdx_alerts-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: mdx_alerts-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.4.0-77-generic

File hashes

Hashes for mdx_alerts-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd3dc6435e03817e61af4503424030c15da9ff3978cda84661de9f16da5516b6
MD5 a8bdc36f5638bb11f99aca9e623481cf
BLAKE2b-256 509f3c7f8cef0ce6de59aa0276e2368228f20b723efc47b8141b72025d4287cf

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