Skip to content

KyleKing/mdformat-admon

Repository files navigation

mdformat-admon

Build Status PyPI version

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.

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

repos:
  - repo: https://github.com/executablebooks/mdformat
    rev: 0.7.18
    hooks:
      - id: mdformat
        additional_dependencies:
          - mdformat-admon

pipx/uv

pipx install mdformat
pipx inject mdformat mdformat-admon

Or with uv:

uv tool run --from mdformat-admon mdformat

HTML Rendering

To 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>

Contributing

See CONTRIBUTING.md

About

An mdformat plugin for "python-markdown" admonitions

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages