mdformat-gfm-alerts
An mdformat plugin for GFM Alerts. For the JS markdown-it equivalent, see antfu/markdown-it-github-alerts
Scope
By default, this package targets the alert syntax GitHub itself renders: [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], and [!CAUTION] alone on their own line, per GitHub's alerts spec. Custom titles ([!TIP] Title) and fold indicators aren't part of that spec, so this package folds trailing text on the marker line into the alert body instead of treating it as a title, matching how GitHub itself would render it.
Obsidian's callout syntax (open-ended types, fold indicators, and custom titles) is where this convention originates. Hugo's alert syntax mirrors just the custom-title/fold grammar, restricted to GFM's five types. Pass --custom-title (or the custom_title option, see Configuration) to preserve an inline title on the canonical [!TYPE] line instead of folding it into the body. This package still won't support fold indicators or Obsidian's open-ended callout types. For that:
- mdformat-hugo bundles this package alongside Hugo-specific shortcode and markdown-attribute formatting
- mdformat-obsidian fully supports GFM-style alerts plus custom titles, folding, and Obsidian's open-ended callout types
Configuration
--custom-title (CLI), custom_title = true under [plugin.gfm_alerts] (.mdformat.toml), or options={"custom_title": True} (API) preserves an inline custom title on the canonical [!TYPE] line instead of folding it into the body:
<!-- Strict GFM (default): -->
> [!TIP]
> Custom title
> Body.
<!-- With --custom-title: -->
> [!TIP] Custom title
> Body.
mdformat Usage
Add this package wherever you use mdformat and the plugin will be auto-recognized. No additional configuration necessary. See additional information on mdformat plugins here
pre-commit / prek
repos:
- repo: https://github.com/executablebooks/mdformat
rev: 1.0.0
hooks:
- id: mdformat
additional_dependencies:
- mdformat-gfm-alerts
uvx
uvx --with=mdformat-gfm-alerts mdformat
Or with pipx:
pipx install mdformat
pipx inject mdformat mdformat-gfm-alerts
HTML Rendering
To generate HTML output, gfm_alerts_plugin can be imported from mdit_plugins. For more guidance on MarkdownIt, see the docs: https://markdown-it-py.readthedocs.io/en/latest/using.html#the-parser
from markdown_it import MarkdownIt
from mdformat_gfm_alerts.mdit_plugins import gfm_alerts_plugin
md = MarkdownIt()
md.use(gfm_alerts_plugin) # pass custom_title=True to preserve inline custom titles
text = """
> [!WARNING]
> This is the warning text
"""
md.render(text)
# <div class="markdown-alert markdown-alert-warning">
# <p class="markdown-alert-title">Warning</p>
# <p>This is the warning text</p>
# </div>
Contributing
See CONTRIBUTING.md
Release files for mdformat-gfm-alerts 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mdformat_gfm_alerts-2.1.0.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mdformat_gfm_alerts-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.1 kB
Release files / mdformat_gfm_alerts-2.1.0.tar.gz
| Download URL | mdformat_gfm_alerts-2.1.0.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27673500976f08eb9e53cfa359f2a528c1be12052d3f8358996b9c5b1cc0c5c2
|
|
BLAKE2b-256 checksum How to use checksums |
bf1798382efef9d4a95fef60f1b5bf9e79a5f62f6698c747d2c99baacdf4cff8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 26, 2026.
Transparency logRelease files / mdformat_gfm_alerts-2.1.0-py3-none-any.whl
| Download URL | mdformat_gfm_alerts-2.1.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81f63efa9b2e6e343e63cdc2cede9f29c3f4c242ebc6a4d9cffeaa1b58d2a170
|
|
BLAKE2b-256 checksum How to use checksums |
17b7df953bacca701b498a616bd12be66876c9dac17fe0a44f9fed65a5b53f04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 26, 2026.
Transparency log