All Projects → valentine195 → obsidian-admonition

valentine195 / obsidian-admonition

Licence: MIT license
Adds admonition block-styled content to Obsidian.md

Programming Languages

typescript
32286 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
SCSS
7915 projects

Projects that are alternatives of or similar to obsidian-admonition

oz-image-in-editor-obsidian
This Obsidian plugin to view Images, Transclusions, iFrames and PDF Files within the Editor without a necessity to switch to Preview.
Stars: ✭ 243 (-58.18%)
Mutual labels:  obsidian-plugin
obsidian-query2table
Represent files returned by a query as a table of their YAML frontmatter (for obsidian.md)
Stars: ✭ 24 (-95.87%)
Mutual labels:  obsidian-plugin
obsidian-core-search-assistant-plugin
An Obsidian plugin to enhance built-in search: keyboard interface, card preview, bigger preview
Stars: ✭ 59 (-89.85%)
Mutual labels:  obsidian-plugin
nldates-obsidian
Work with dates in natural language in Obsidian
Stars: ✭ 263 (-54.73%)
Mutual labels:  obsidian-plugin
obsidian-linked-data-vocabularies
Add linked data to the YAML of your Obsidian notes.
Stars: ✭ 53 (-90.88%)
Mutual labels:  obsidian-plugin
obsidian-pangu
为 Obsidian 笔记加上「盘古之白」,排版强迫症者的福音。 | A small plugin aims to add space between Chinese Characters and English Alphabet, and it is a boon for typographically compulsive people.
Stars: ✭ 40 (-93.12%)
Mutual labels:  obsidian-plugin
obsidian-link-archive
Link Archive plugin for Obsidian
Stars: ✭ 94 (-83.82%)
Mutual labels:  obsidian-plugin
obsidian-vale
A Vale client for Obsidian.
Stars: ✭ 57 (-90.19%)
Mutual labels:  obsidian-plugin
obsidian-task-collector
Plugin for https://obsidian.md/ that assists with managing tasks within a document.
Stars: ✭ 77 (-86.75%)
Mutual labels:  obsidian-plugin
obsidian-metatemplates
Take advantage of YAML front-matter in generating notes from templates (for obsidian.md)
Stars: ✭ 68 (-88.3%)
Mutual labels:  obsidian-plugin
obsidian42-text-transporter
Text Transporter - advanced text management for Obsidian. Part of the Obisidan42 family of Obsidian plugins.
Stars: ✭ 100 (-82.79%)
Mutual labels:  obsidian-plugin
Highlightr-Plugin
A minimal and aesthetically pleasing highlighting menu that makes color-coded highlighting much easier 🎨.
Stars: ✭ 321 (-44.75%)
Mutual labels:  obsidian-plugin
obsidian-plugin-dynamic-toc
An Obsidian plugin for creating Tables of Contents that stay updated with your document
Stars: ✭ 174 (-70.05%)
Mutual labels:  obsidian-plugin
obsidian-metatable
An Obsidian plugin to display the frontmatter section as a fully expanded table.
Stars: ✭ 115 (-80.21%)
Mutual labels:  obsidian-plugin
obsidian-embedded-note-titles
No description or website provided.
Stars: ✭ 50 (-91.39%)
Mutual labels:  obsidian-plugin
obsidian-rtl
RTL support for Obsidian.md
Stars: ✭ 51 (-91.22%)
Mutual labels:  obsidian-plugin
obsidian-search-on-internet
Add context menu items in Obsidian to search the internet.
Stars: ✭ 79 (-86.4%)
Mutual labels:  obsidian-plugin
ObsidianBookmark
Chrome extension and nodejs server to allow web clipping to Obsidian.
Stars: ✭ 122 (-79%)
Mutual labels:  obsidian-plugin
obsidian-journey-plugin
Discover the story between your notes in Obsidian
Stars: ✭ 93 (-83.99%)
Mutual labels:  obsidian-plugin
note-folder-autorename
Obsidian plugin to support folder-overview notes by keeping their folder in sync
Stars: ✭ 36 (-93.8%)
Mutual labels:  obsidian-plugin

Obsidian Admonition

Adds admonition block-styled content to Obsidian.md, styled after Material for MkDocs

Please note!

Obsidian 0.14 adds support for Callout boxes!

With this change, Admonitions will be transitioning to a plugin that enhances the core callout box feature.

What does this mean, you might ask?

  1. All of your existing code block admonitions will continue to work, and will always work!
  2. You can continue to use Admonitions to create custom types, and all of your custom types will just work as a callout, without you having to do anything!
  3. If you have any Microsoft Document syntax admonitions, they will have to be converted to the new callout box syntax - there is a button in Admonition settings to auto-convert these for you.
  4. You can use Admonitions to set default titles, default collapse states, or defaulting to not having a title.
  5. Admonitions adds helpful editor suggestors for quickly entering your custom callout boxes.
  6. Admonitions adds helpful commands for inserting callout boxes, including the ability to register commands for specific types.

Usage

Place a code block with the admonition type:

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

Becomes:

Options

```ad-<type> # Admonition type. See below for a list of available types.
title:                  # Admonition title.
collapse:               # Create a collapsible admonition.
icon:                   # Override the icon.
color:                  # Override the color.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla.

```

Please note that as of 4.4.1, the title, collapse, icon and color parameters must be at the top of the block, in any order.

Title

The admonition will render with the type of admonition by default. If you wish to customize the title, you can do so this way:

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

Custom titles are rendered as Markdown, so they support the full Obsidian Markdown syntax.

Leave the title field blank to only display the admonition.

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

Collapsible

Use the collapse parameter to create a collapsible admonition.

collapse: open will start the admonition opened on render, but allow collapse on click.

If a blank title is provided, the collapse parameter will not do anything.

Admonitions may be set to be collapsible by default in settings.

Icon

The admonition icon can be overridden using the icon parameter. The icon name entered must be the exact icon name from FontAwesome or RPGAwesome.

```ad-note
icon: triforce

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla.

```

Color

The admonition color can be overridden using the color parameter. The color entered must be an RGB triad.

```ad-note
color: 200, 200, 200

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla.

```

No Content

An admonition with no content will render as just the title block.

```ad-note
```

Nesting Admonitions

Nesting admonitions may be done by increasing the number of backticks.

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

Rendering Code Blocks inside Admonitions

Code blocks may be nested inside admonitions using a method similar to Nesting Admonitions above.

Additionally, for a single layer, the ~~~ markdown codeblock syntax may be used:

````ad-info

```ad-bug
title: I'm Nested!
~~~javascript
throw new Error("Oops, I'm a bug.");
~~~
```

```javascript
console.log("Hello!");
```

````

Admonition Types

The following admonition types are currently supported:

Type Aliases
note note, seealso
abstract abstract, summary, tldr
info info, todo
tip tip, hint, important
success success, check, done
question question, help, faq
warning warning, caution, attention
failure failure, fail, missing
danger danger, error
bug bug
example example
quote quote, cite

See this for a reference of what these admonitions look like.

The default admonitions are customizable by creating a user-defined admonition of the same name.

Custom Admonitions & Callouts

Custom admonitions may be created in settings. Creating a custom admonition will also enable it to be used as an Obsidian callout.

Creating a new admonition requires three things: the type, the icon to use, and the color of the admonition.

Only one admonition of each type may exist at any given time; if another admonition of the same type is created, it will override the previously created one.

If a default admonition is overridden, it can be restored by deleting the user-defined admonition.

Please note that by default, the background color of the title is simply the color of the admonition at 10% opacity. CSS must be used to update this.

Images as Icons

Images can be uploaded to use as an admonition icon instead of an icon from a downloaded icon set.

These images will be resized to 24px x 24px to be stored in the plugin's saved data.

To remove an image icon, simply choose an icon in the icon chooser text box.

Global Commands

Several commands are available for the plugin by default.

Collapse and Open All Admonitions In Note

If these two commands are triggered with an open note, all collapsible admonitions will be collapsed or open respectively.

Insert Admonition

This will open a modal where the admonition type, title and collapse behavior can be set, then the generated admonition code block will be inserted into the open editor.

Admonition-specific commands

Commands may be registered for each custom admonition type to insert them into an open note by clicking the Register Commands button in Settings.

3 commands will be registered: Insert <type> Callout, Insert <type>, and Insert <type> with Title.

Insert Callout

The selected type will be inserted as an Obsidian callout, and any selected text will be included with it.

Insert

The selected type will be inserted as a codeblock admonition, and any selected text will be included with it.

Insert with Title

The selected type will be inserted as a codeblock admonition, and any selected text will be included with it. The title: parameter will also be added and the cursor will be placed at that line.

Mermaid Graphs

Mermaid graphs are supported by Admonitions, but with some caveats:

  1. You cannot combine mermaid graphs and embeds/transclusions.
  2. Mermaid graphs do not work in collapsed-by-default admonitions.

Non-code block Admonitions

This syntax has been officially removed as of Admonitions 7.0.0.

Use the Obsidian Callout box syntax instead!

As of version 6.0.0, there is a new setting: Enable Non-codeblock Admonitions.

This setting is highly experimental and may not work as expected, and there are a few caveats listed at the end of this section to keep in mind.

This setting allows for creating an admonition without wrapping it in a code block, which means that links and tags will sync into Obsidian's cache. A non-codeblock admonition may be created using the following syntax:


!!! ad-<type> Title goes here!

content

--- admonition

This will create the appropriate admonition type, embed the content, and give it the supplied title.

Titles

Titles should be placed after the admonition block. Currently, markdown in titles is not supported.

An empty title can be created by either placing two spaces after the admonition type:


!!! ad-<type>

content

--- admonition

or by placing empty double quotes:


!!! ad-<type> ""

content

--- admonition

Collapsible

A collapsible admonition may be created using the following syntax:


??? ad-<type> Title goes here!

content

--- admonition

A collapsible admonition may default to "open" by appending a +:


???+ ad-<type> Title goes here!

content

--- admonition

Caveats

  1. Changes to the admonition after render require the cache to be cleared. The note must be closed and re-opened (and sometimes, a different note must be opened first).
    1. This is all changes, including the admonition type, title, content, even whether or not a collapsible admonition is open or closed initially.
  2. Nested admonitions are not currently supported.

If you experience any bugs using this setting, please create an issue and I will look into them.

Microsoft Document Syntax

This syntax has been officially removed as of version 8.0.0.

Use the Obsidian Callout box syntax instead!

As of v6.8.0, an additional non-code block syntax can be used that is inspired by the Microsoft Document Syntax to render admonitions.

⚠️ Please note:

Unlike the Microsoft Document Syntax, the type is not required to be upper case.

The plugin will use an exact-match first, then try to find a case-insensitive match.

> [!quote]
> This is an admonition!

This syntax can also be used on indented code blocks:

    [!quote]
    This is an admonition!

Title

A title can be added to the MSDoc-style admonition by appending it after the type.

> [!quote: This is the title!]
> This is an admonition!

Like the code block syntax, providing an empty title will remove the title from the rendered admonition.

> [!quote:]
> This admonition won't have a title!

Collapse

Collapse can be set by appending the following characters after the brackets:

Character Collapse Type
+ open
- closed
x none

Publish

Obsidian plugins do not work on publish sites; however, version 6.4.0+ has an option to generate a JavaScript file that can be used on Publish sites with custom domains.

Obsidian Publish only allows external JavaScript on publish sites with custom domains. If your Publish is ran through Obsidian, this will not work.

Instructions:

  1. Go the Admonition settings tab and click the "Generate JS for Publish" button.
  2. Save the JavaScript file.
  3. Copy the contents of the JS file to your publish.js file.
  4. Add the contents of the assets/main.css file to your publish.css file.

Please note that I can give no guarantees of stability on your publish site. Other JavaScript you include may conflict with this file. If you run into an issue using it, please create an issue on this repository and I will try to help you.

Icon Packs

Additional icon packs can be downloaded in settings.

Adding Icon Packs

Want to add an existing icon pack? Make a pull request with the following:

  1. Add a new folder in the icons folder with the name of your icon set.
  2. Create an icons.json file that has the icons defined as an Object. Please see the Octicons json for reference.
  3. Put your icon pack's information in the two variables in the Icon Packs file.

Settings

Custom Admonition Types

Custom admonition types can be created and managed in this section of the settings.

Export Custom Types as CSS

This button will generate a CSS snippet that you can save and use for your custom callout types.

Admonition Settings

Settings specific to admonitions are managed in this section.

Add Drop Shadow

A drop shadow will be added to admonitions by default.

If this setting is off, rendered admonitions will receive the .no-drop class.

Collapsible By Default

All admonitions will be collapsible by default, unless collapse: none is set in the admonition parameters.

Default Collapse Type

⚠️ This setting is only available when Collapsible By Default is true.

Set the default collapse type used when setting an admonition collapsible by default.

Add Copy Button

A "Copy Content" button will be added to the top-right corner of the admonition & callout content.

Parse Titles as Markdown

Turn this setting off to prevent admonition titles from being rendered as markdown.

Set Admonition Colors

Controls whether or not a rendered admonition will receive a color.

Turn this off to totally control color via CSS.

Hide Empty Admonitions

Admonitions with no content are hidden by default.

⚠️ Please note that this only works for Admonitions that have no text content whatsoever.

Icon Packs

Use Font Awesome Icons

The plugin comes pre-bundled with the entire Font Awesome Free icon set. Turn this setting off to not include them in the icon picker.

Existing custom Admonitions that use Font Awesome icons will continue to work.

Additional Icon Packs

Additional icon packs can be downloaded to supplement the included Font Awesome Free icon set.

Downloading an icon pack requires an internet connection.

Current additional icon packs available are the Octicons set and the RPG Awesome set.

📝 For backwards compability, if an Admonition was created prior to version 7.0.0 using an RPG Awesome icon, the pack will try to be downloaded.

Additional Syntaxes

Obsidian 0.14 has introduced Callout boxes to its core functionality using a similar syntax to the Microsoft Document callouts.

This has rendered the Microsoft Document syntax for Admonitions obsolete, but Admonitions can still be used to create and manage your custom callout types.

Your existing code block Admonitions will always work!

Enable Non-codeblock Admonitions

This setting has been removed as of version 7.0.0.

It is recommended to use the Obsidian Callout box instead.

Enabled use of !!! ad-<type> style admonitions. No longer supported, will be removed in a future version.

Allow Microsoft Document Syntax

This syntax has been officially removed as of version 8.0.0.

Use the Obsidian Callout box syntax instead!

Enables use of the Microsoft Document Syntax for blockquote admonitions.

Use Microsoft Document Syntax for Indented Code Blocks

This syntax has been officially removed as of version 8.0.0.

Use the Obsidian Callout box syntax instead!

Enables use of the Microsoft Document Syntax for indented code blocks.

Render Microsoft Document Syntax in Live Preview

This syntax has been officially removed as of version 8.0.0.

Use the Obsidian Callout box syntax instead!

Enables use of the Microsoft Document Syntax in live preview.

This feature is still under development and you may experience rendering bugs.

Convert MSDoc Admonitions to Callouts (v8.0.0+)

This button can be used to convert any existing Microsoft Document syntax Admonitions to the new Callout box syntax.

Advanced Settings

Markdown Syntax Highlighting

Enable syntax highlighting when editing admonition code blocks.

Sync Links to Metadata Cache

The plugin will attempt to syncronize links to the metadata cache to be displayed in graph view.

This setting is experimental. Links will only be synced when rendered in an admonition and they will not persist if you close and re-open Obsidian.

Please see this issue for more information.

If you require links to be fully synced, it is recommended to use the Microsoft Document Syntax.

Generate JS for Publish

Use this setting to enable Admonitions on custom-domain Obsidian Publish websites.

See Publish for more information.

Todo

No additional features are planned at this time. If there is a feature missing that you would like to see, please open an issue.

  • Add the ability to collapse the admonition
  • Custom admonitions
  • Settings tab to customize icon and color of all admonitions
  • Ability to render markdown inside an admonition

Installation

From within Obsidian

From Obsidian v0.9.8, you can activate this plugin within Obsidian by doing the following:

  • Open Settings > Third-party plugin
  • Make sure Safe mode is off
  • Click Browse community plugins
  • Search for this plugin
  • Click Install
  • Once installed, close the community plugins window and activate the newly installed plugin

From GitHub

  • Download the Latest Release from the Releases section of the GitHub Repository
  • Extract the plugin folder from the zip to your vault's plugins folder: <vault>/.obsidian/plugins/
    Note: On some machines the .obsidian folder may be hidden. On MacOS you should be able to press Command+Shift+Dot to show the folder in Finder.
  • Reload Obsidian
  • If prompted about Safe Mode, you can disable safe mode and enable the plugin. Otherwise head to Settings, third-party plugins, make sure safe mode is off and enable the plugin from there.

Updates

You can follow the same procedure to update the plugin

Warning

This plugin comes with no guarantee of stability and bugs may delete data. Please ensure you have automated backups.

TTRPG plugins

If you're using Obsidian to run/plan a TTRPG, you may find my other plugin useful:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].