Convert GitHub admonitions to mkdocs syntax when building docs.
Project description
GitHub 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.
[!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
mkdocs
admonitions to be generated. All admonitions will be
converted to non-collapsed title-less admonitions.
GitHub admonitions feature two types which are not supported by mkdocs
:
danger
and important
. In converting these admonitions, we will preserve their title,
but use the caution
and warning
symbol and color, respectively.
Examples
Here is a gallery with various admonitions. They should show up correctly on the built documentation too!
[!tip] This is normally formatted. Type in lower case. No extra spaces. It contains two lines in markdown, but only a soft linebreak.
[!CAUTION]
This admonition has:
- ALL CAPS in the type
- a list
Note that this admonition uses the "danger" symbol with "Caution" title.
[!Important] This contains
inline
andimport this # python code in ticksand code block with spaces
Note that this admonition uses the "warning" symbol with "Important" title.
[!note] And this admonition contains an empty line
That only has a
>
character in markdown.
[!warning] Admonitions may contains quotes
Quotes always contain great wisdom.
But pay attention! There may be admonitions which are really just code:
> [!note]
> This is not an admonition.
Disclaimer
This is an independent project and not affiliated with GitHub in any way.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mkdocs_github_admonitions_plugin-0.0.2.tar.gz
.
File metadata
- Download URL: mkdocs_github_admonitions_plugin-0.0.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459bdce3a95cf70d93eac2d1af0bc4b6ee851c679f8e2bc8940454292bd4e5b4 |
|
MD5 | 8c237838f6ee9e9a594718f96db6668f |
|
BLAKE2b-256 | e1cd726e1a9a3b70b24a257c3a7b2daaa45789d571fae05f6fe1e303ebb31fd1 |
File details
Details for the file mkdocs_github_admonitions_plugin-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_github_admonitions_plugin-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2876f311e3b537f2df1cf0a732701381bdbd409b9924a004f82d1d2dc8c4f068 |
|
MD5 | d4edc58525b8dbfece642d5080338fa7 |
|
BLAKE2b-256 | a366bb08184baf7dd2eb125933438a2a9f8b39a148d5991681ca39de4a98260d |