Admonition plugin

The plugin is now part of the community list, so if you have it installed, please re-install it from there.

Thanks!

5 Likes

A really great plugin! Changeable titles possibly with customizable images would make it perfect.

Thanks for this!

Hi all,

I was asked by the Obsidian mods to update the syntax of the plugin to avoid colliding with other plugins.

As of 2.0.0, all admonitions must be prefixed with ad-

For example:

```ad-note
Lorem ipsum dolor sit amet.
```
5 Likes

I really like the idea of the admonition plugin! I use Obsidian Export to export my Obsidian Vault to standard markdown, after that I use MkDocs and the Material Plugin to generate a static html page.

The result actually looks very nice (and even includes mermaid diagrams).
Iā€™d like to use admonitions as well, but I guess itā€™s difficult, because the format of the Admonition Plugin is quite different that the admonition format of the Mkdocs Material Admonition Plugin

Format MKdocs Material Admonitions:

!!! note
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod
    nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor
    massa, nec semper lorem quam in massa.

Format Admonition Plugin:

```ad-note
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla.
```

:thinking:

1 Like

Hello,

What do you think of having alternate stylings in the form of Cards? Examples of Card elements are linked below: UI Cards

3.0.0 Released

Hi all. Just released 3.0.0 that adds the ability to create custom admonitions types, where you can customize the title, icon and color.

You can use these custom admonition types to override the default included admonitions, too.

In order to support this, I did remove the CSS color definitions for the default admonition types. Each admonition still receives the .admonition-<type> class, but the class has no styling in it by default. If you were changing the color of these admonitions through a CSS snippet before (or a theme), it can now be done in a single line using a css variable set to an RGB triad:

.admonition-note {
    --admonition-color: 68, 138, 255 !important;
}

However, it would probably be easier to just override the admonition with a user-defined one.

4 Likes

@arg

Iā€™d like to use admonitions as well, but I guess itā€™s difficult, because the format of the Admonition Plugin is quite different that the admonition format of the Mkdocs Material Admonition Plugin

This is because of the way Obsidianā€™s API is set up. These admonitions are created as ā€œmarkdown code block processorsā€, so when Obsidian sees the ā€œlanguageā€ of each admonition (ad-note, for example), it just runs the processor I setup for that admonition type.

The MkDocs !!! syntax would require adding a whole new Markdown syntax to Obsidian, which Iā€™m not willing to do. If the Obsidian devs add the ability to do this properly (or add the !!! syntax), Iā€™ll add this. If I get some free time, Iā€™ll take a look and see if I can hook into Obsidian export if its installed and setup a parser for these blocks.

For now you could run the output through a RegEx replace and change them, though.

Edit: also, if other markdown code block processors (such as mermaid) work with the export plugin, theyā€™re probably hardcoded in.

@amarionette

What do you think of having alternate stylings in the form of Cards?

This would be pretty easy, but it would require an additional parameter field in the admonition.

An alternative, in 3.0.0, would be to create a custom admonition (like ad-card) and then override the CSS for that admonition type:

.admonition-card {
    /* ... */
}

.admonition-card > .admonition-title {
    /* ... */
}

/* etc */

This would let you completely customize the look.

Let me know which option youā€™d prefer. If you need, I can help you with the CSS.

1 Like

Can you describe the process for creating a new custom admonition type? I can work on the CSS bit once I get this part out of the way. Thanks!

Sure. If youā€™ve updated to 3.0.0, there should be a settings tab for the plugin. New admonition types can be created in there.

1 Like

I do not know if I am missing something, but is it possible to sync custom types with the mobile app? The custom types I use have not synced.

Custom types are stored in the <VAULT>/.obsidian/obsidian-admonition/data.json file (this is where Obsidian saves plugin data by default).

If this file is synced to your mobile vault, theyā€™ll sync. Iā€™m not sure if these files are synced via Obsidian Sync yet - I do not have Obsidian Sync nor am I in the mobile beta. You could copy it manually for now, if not.

I think the key will be ensuring the settings are applied to both configurations (if you use separate config dirsā€¦ youā€™d need to copy your changes into the mobile config dir, e.g.)

The data.json file will sync between desktops, but it does not sync with mobileā€”none of the plugins I use on the desktop version sync with the mobile app. This is when using Obsidian Sync.

@valentine.195:

Thanks for the explanation. Totally understandable, that the MKDocs !!! syntax doesnā€™t really work well with the normal markdown blocks processing.
Iā€™ll try to regexp it as you proposed! :+1:

FYI: mermaid works for me because it is a normal code block and the export doesnā€™t change it. And mkdocs is so smart to also detect a mermaid code block and use javascript to render it.

Thank you! Ill give it a go

Hi all. Just wanted to let you know that as of version 4.0.0, you can now nest admonitions inside each other. Please see Nesting Admonitions for documentation on how to nest admonitions.

Admonitions may be nested inside each other indefinitely using the Python Markdown syntax.

:warning: Please note that you still must create the initial admonition using the code block syntax.

Example:

```ad-note
title: Nested Admonitions
collapse: open

Hello!

!!! ad-note
	title: This admonition is nested.
	This is a nested admonition!
	!!! ad-warning
		title: This admonition is closed.
		collapse: close


This is in the original admonition.
```

nested

6 Likes

@valentine.195 How do I use the new Admonition types?

I have created ad-task, added an icon, modified the color and saved.

title: Task -- Timeline
content: Tasks linked to a goal, with a specific date or time-frame
collapse:

Restarted Obsidian, but it still is not working, as expected.

Has anyone been able to add the custom Admonition types?

1 Like

Did you use the ```ad-<type> syntax? It has to be exactly the same (e.g., if your new type is Task, it would be ```ad-Task).

Iā€™m using several custom admonition types in my own personal notes.

1 Like

AdmonitionNewType2021-05-05_14-53-08 AdmonitionNewType2021-05-05_14-53-08-02

I believe, I added it correctly see the screenshots. Thanks for your time.

1 Like

Ah, I see. You can just enter ā€œtaskā€ in the ā€œadmonition typeā€ section. The description of that field is very misleading, sorry. Iā€™ll update it to be more clear.

In that specific case, what you would actually use to create your custom admonition is ```ad-ad-task

2 Likes