Admonition plugin

Sounds awesome!
What kind of versioning do you use?

Once it’s submitted as a community plugin, I’ll go to 1.0.0 and then use typical semantic versioning from there, but honestly sometimes I don’t follow it well (like this release should have been a minor version update).

3 Likes

Very nice indeed. Tried it out and look forward for using it
Thanks @valentine.195

I am still using 0.0.4 until it is available on the Community Plugins, but I just noticed this. Could this be fixed somehow? The breaks don’t work. I know that it is because it gets turned into a <p> tag. So either each line has a new <p> tag, add <br /> or leave it as <pre> ? Just some suggestions.

1 Like

0.2.0 Release

  • Uses Obsidian’s Markdown renderer to render the admonition content, instead of just placing it all inside a <p> tag.
  • Removed requirement to use the content: flags if title: or collapse: is used

This should fix that issue. The content should render exactly like regular markdown outside of code blocks.

The only thing I could find that gives the admonition block fits is nested code – if its the last thing in the block it will render fine (and even do the prism highlighting), but if there’s content after it, that content will be placed outside the block.

image

2 Likes

Please also regard the Pandoc fenced divs and pandoc-latex-admonition a possibility.

I have been using these with Pandoc and LaTeX in times before Obsidian …

Hi there! Your plugin is a great shot, yet I’m struggling with customizing default titles for each text block. For example, I’d like not to rename “Note” every time with the “content:” row but to give it another default title. Any suggestions?

In version 0.2.0 I removed the requirement to have the content: parameter if you have a unique title, which helps.

Right now, there isn’t the ability to do custom default titles, but I was planning on adding it. This is a little tricky because the plugin is telling Obsidian to treat each admonition type as a code block language (like javascript or mermaid), so it could collide with other languages and exhibit weird behavior.

2 Likes

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.)