Markdown Callouts
markdown-callouts is a Python-Markdown extension that enhances documentation with admonition-style callouts. It supports various syntaxes, including a flexible original style (e.g., `NOTE:`), collapsible blocks (`>? TIP:`), and the GitHub 'alerts' syntax (`> [!NOTE]`). The current version is 0.4.0, and new features are added incrementally, often focusing on compatibility with existing Markdown parsers and popular documentation tools like MkDocs.
Common errors
-
Markdown extension 'callouts' not found
cause The `markdown-callouts` package, which provides the 'callouts' extension, is either not installed or not accessible in the current Python environment.fixEnsure the package is installed: `pip install markdown-callouts`. If using a virtual environment, activate it before running your build or script. -
SyntaxError: invalid syntax (when trying to write `NOTE: This is a note.` directly in Python code)
cause Attempting to use Markdown callout syntax directly as Python code. Markdown syntax is not valid Python.fixThe callout syntax is for Markdown files (`.md`). Write your callouts in your Markdown content, then process those files using a Markdown parser (e.g., `markdown.markdown(text, extensions=['callouts'])`) or a documentation generator like MkDocs. -
Callouts are not rendering or appear as plain blockquotes.
cause Incorrect callout syntax, leading to the extension not recognizing the block, or the extension itself is not enabled.fix1. Verify the exact callout syntax (e.g., `NOTE: ` requires a space after the colon, `> [!WARNING]` needs the exact `> [!TYPE]` pattern, including the space after `>`). 2. Ensure the correct extension (`callouts` or `github-callouts`) is properly enabled in your configuration.
Warnings
- gotcha The package provides two distinct callout extensions: `callouts` and `github-callouts`, which implement different syntaxes.
- gotcha Like all Python-Markdown extensions, `markdown-callouts` must be explicitly enabled to function.
- gotcha Callout syntax has evolved across versions, introducing new features with specific patterns.
Install
-
pip install markdown-callouts
Imports
- callouts
mkdocs.yml: - callouts Python: extensions=['callouts']
- github-callouts
mkdocs.yml: - github-callouts Python: extensions=['github-callouts']
Quickstart
# mkdocs.yml site_name: My Docs markdown_extensions: - callouts - github-callouts # For GitHub-style alerts, v0.4.0+ # docs/index.md content example: # NOTE: This is a standard callout. # # > [!WARNING] # > This is a GitHub-style alert. # # >? TIP: **Click me for more info.** # > # > This content is collapsible.