How to add admonition from obisidian to mkdocs
There's a neat trick with obsidian where you can add little expandable text boxes.
It looks like this:
> [!info]- Click to Expand Me!
> > Hello!!!
Click to Expand Me!
Hello!!!
With html, that would look something like this:
<details>
<summary>Click to Expand Me!</summary>
<blockquote>Hello!!!</blockquote>
</details>
By default, with mkdocs (no callouts plugin), that same Obsidian markdown syntax renders as this instead. Plain Markdown has no idea what [!info]- means, so it just falls back to a plain nested blockquote with that text sitting there literally, not styled or collapsible at all:
<blockquote>
<p>[!info]- Click to Expand Me!</p>
<blockquote>
<p>Hello!!!</p>
</blockquote>
</blockquote>
So to render the obsidian style in mkdocs, we just need to add a little plugin.
-
Install it (into your venv):
venv/bin/pip install mkdocs-callouts -
Add to
mkdocs.yml— the plugin plus the markdown extensions the output relies on:plugins: - search - callouts # converts Obsidian > [!note] → Material admonition markdown_extensions: - admonition # renders the callout boxes - pymdownx.details # needed for collapsible callouts - pymdownx.superfences
With that in place, the exact same Obsidian syntax at the top of this page renders as the real, styled, collapsible box.