An mdformat plugin for formatting python-markdown admonitions and rendering the associated HTML.
Warning
mdformat-admon and mdformat-mkdocs>=4.0.0 are no longer compatible. If you have both, you'll want to remove mdformat-admon
The stylistic formatting for mkdocs differs from Python Markdown (#22), so this package is now only for Python Markdown without mkdocs.
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
repos:
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.19
hooks:
- id: mdformat
additional_dependencies:
- mdformat-admonpipx install mdformat
pipx inject mdformat mdformat-admonOr with uv:
uv tool run --from mdformat-admon mdformatTo generate HTML output, python_markdown_admon_plugin can be imported from mdit_plugins. More plugins will be added in the future. 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_admon.mdit_plugins import python_markdown_admon_plugin
md = MarkdownIt()
md.use(python_markdown_admon_plugin)
text = '!!! note ""\n *content*'
md.render(text)
# <div class="admonition note">
# <p><em>content</em></p>
# </div>See CONTRIBUTING.md