Skip to content

oprypin/markdown-callouts

Repository files navigation

markdown-callouts

Extension for Python-Markdown: a classier syntax for admonitions

PyPI License GitHub Workflow Status

Installation

pip install markdown-callouts

If using MkDocs, enable the extension in mkdocs.yml:

markdown_extensions:
  - callouts

Continue to the documentation site.

Usage

This adds a new block-level syntax to Markdown, to put a paragraph of text into a block that's specially highlighted and set apart from the rest of the text.

Example:

NOTE: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
massa, nec semper lorem quam in massa.

Result, using mkdocs-material:

Screenshot

Collapsible blocks also have a syntax for them:

>? NOTE: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
> nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
> massa, nec semper lorem quam in massa.

This instead shows up as an initially-closed <details> block.

Graceful degradation

This extension produces the same results as the admonition extension, but with a syntax that is much less intrusive and has a very reasonable fallback look for "vanilla" renderers.

E.g. compare what you would've seen above if we actually wrote that Markdown and fed it to GitHub's Markdown parser:

"Callouts" syntax

NOTE: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.

"Admonition" syntax

!!! note

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
massa, nec semper lorem quam in massa.

Support GitHub "alerts" style of admonitions

To enable, add to mkdocs.yml:

markdown_extensions:
  - github-callouts

This can be used instead of, or in addition to, the other callouts extension shipped by this package. This adds support for GitHub-style alerts.

The syntax is:

> [!NOTE]
> Lorem ipsum dolor sit amet.

Continue to the documentation site.