Convert GitHub admonitions to mkdocs syntax when building docs.
Maintained. Last release 3 weeks ago, commits in 1 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install mkdocs-github-admonitions-pluginGitHub Admonitions for MkDocs
Convert GitHub admonitions
to mkdocs admonitions
when building docs, so that you can have admonitions on GitHub and in the
documentation from the same file.
Now also supporting GitLab admonitions (alerts, thanks @pismy!).
[!TIP] This is an admonition. They are a useful tool to attract attention to information.
Usage
To install the plugin:
python -m pip install mkdocs-github-admonitions-plugin
Then in your mkdocs.yml file, add the plugin:
plugins:
- gh-admonitions
Now you can write GitHub-compatible admonitions, and they will be
automatically converted when used in mkdocs pages.
Why is this needed?
Both GitHub and mkdocs support admonitions from their markdown flavors.
Unfortunately, their flavors are different.
A GitHub admonition is written like this:
> [!TIP]
> This is the GitHub admonition syntax.
And mkdocs admonitions are written like this:
!!! tip
This is the mkdocs-materials admonition syntax.
So an admonition in your documentation will render correctly on either GitHub
or in your mkdocs pages, but not both. With this plugin, you write
the admonition once in GitHub syntax, and it will still show correctly in the
built mkdocs pages!
Limitations
The mkdocs admonitions are much more powerful. They can feature
titles. They have more types, and you can add custom ones. You can render inline
admonitions. They can be collapsable, and be collapsed by default.
And much more.
But since the GitHub syntax has none of that, this tool can not offer such admonitions to be generated. All admonitions will be converted to non-collapsed title-less admonitions.