Plugin: Markdown Alerts and Formatting Commands [v1.4.1]

Markdown Alerts and Formatting Commands

A Joplin plugin that adds the following functionality to the Markdown editor:

  • renders GitHub-style alerts in the Markdown viewer and Markdown editor
  • adds Markdown editor commands for alerts, blockquotes, and inline formatting (for markdown syntax that joplin's builtin formatting commands don't cover)

test9

NOTE:
This plugin was created entirely with AI tools.

NOTE:
The Rich Text Editor is not supported. Alerts may appear there, but editing in the Rich Text Editor will remove GitHub alert syntax.

1. GitHub Alert Rendering

The plugin supports GitHub-style alert syntax:

  • Markdown viewer: alerts render as styled callouts using markdown-it-github-alerts
  • Markdown editor: alerts are decorated as styled block quotes, with a title line showing the alert type (or custom title) and svg icon based on alert type (similar to the markdown-it-github-alerts styling in the viewer)

Supported alert types:

  • NOTE
  • TIP
  • IMPORTANT
  • WARNING
  • CAUTION

Example:

> [!NOTE]
> Useful information that users should know, even when skimming content.

> [!TIP]
> Helpful advice for doing things better or more easily.

> [!IMPORTANT]
> Key information users need to know to achieve their goal.

> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.

> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.

> [!NOTE] Custom title
> This alert uses a custom title

2. Markdown Editor Commands For Block Structures

The plugin adds toolbar buttons and Edit menu commands for:

  • Insert or Toggle alert
  • Insert or Toggle blockquote

Insert or Toggle alert

Default shortcut: Ctrl + Shift + A

Behavior:

  • On an empty line, insert > [!NOTE] and place the cursor after the marker
  • If the cursor is inside an existing alert, cycle the alert type
  • If the cursor is inside a regular blockquote, convert it into an alert
  • With no selection, convert the current paragraph or line into an alert
  • With a selection, convert the selected paragraphs or lines into an alert

Insert or Toggle blockquote

Default shortcut: Ctrl + Shift + .

Behavior:

  • On an empty line, insert > and place the cursor after the marker
  • With no selection, convert the current paragraph or line into a blockquote
  • With a selection, convert the selected paragraphs or lines into blockquotes

Inline Formatting Commands

Joplin supports various inline Markdown extensions, but the Markdown editor does not provide built-in commands for all of them. This plugin adds commands, toolbar buttons, and Edit menu entries for:

  • Highlight: ==text==
  • Strikethrough: ~~text~~
  • Underline: ++text++
  • Superscript: ^text^
  • Subscript: ~text~

Default shortcuts:

  • Highlight: CmdOrCtrl + Shift + Y
  • Strikethrough: CmdOrCtrl + Shift + ~
  • Underline: CmdOrCtrl + Shift + U
  • Superscript: no default shortcut
  • Subscript: no default shortcut

Command behavior:

  • Empty selection: insert the delimiter pair and place the cursor between them
  • Selected text already fully wrapped in the target format: remove the outer formatting
  • Selection contains one or more inner spans already using the target format: remove only that target formatting
  • Selection contains no target formatting: wrap the selection

For full-line selections, the inline formatting commands are line-aware instead of blindly wrapping the whole block:

  • blank lines are preserved
  • list markers are preserved
  • blockquote markers are preserved
  • heading markers are preserved
  • task list markers are preserved
  • fenced code blocks are left alone
  • leading and trailing spaces stay outside newly inserted delimiters

Examples:

> - abc test

Highlight becomes:

> - ==abc test==
## Heading

Highlight becomes:

## ==Heading==

Settings

The plugin includes settings to enable or disable each editor toolbar button independently.

Available toolbar visibility settings:

  • Alert
  • Blockquote
  • Highlight
  • Strikethrough
  • Underline
  • Superscript
  • Subscript

All toolbar buttons are enabled by default.

These settings only affect the editor toolbar buttons. The commands themselves, menu items, and shortcuts still remain available.

Changing a toolbar visibility setting currently requires restarting the plugin to take effect.

2 Likes

Thanks for this, @bwat47, it has a more distinctive styling that makes admonitions more visible among surrounding text.

1 Like

v1.1.0

Improvements

  • feat: Render alert syntax as title (when custom title isn't present)
  • feat: Enhance the keyboard shortcut/toolbar button command so that it can toggle alert types in existing block quotes
  • fix: Fix faded alert colors/text in markdown editor by setting opacity to 1 so that the alerts don't inherit the 0.7 opacity from joplin's standard block quote styling
  • Improvement: Use alert color for title text

example

2 Likes

Neat implementation of the toggle admonition types with shortcut!

v1.1.1

Improvements

  • feat: Display SVG icons in alert titles in the markdown editor

v1.1.3

  • Fix issue (#7) where alert title wasn't displayed properly in markdown editor when using rich markdown plugin with align list items option enabled
2 Likes

v1.2.0

Improvements

  • feat: Quote/Unquote selected text
  • feat: Update toggle alert command to handle selected text (convert unquoted text to a [!note] alert, or toggle alert type if selected text is already a quote or an alert)

v1.3.0

Improvements

  • The quote/unquote command no longer requires a text selection, its now context aware and will quote/unquote the current paragraph where the cursor is if there's no text selection (or current line if cursor is somewhere that's not considered a paragraph).
  • The quote command will now create a new block quote when invoked on an empty line (making it easier to create quotes on mobile)
  • The alert command was already partially context aware (toggling alert type when cursor is anywhere in a quote or alert), but has been updated so that it can convert the paragraph where the cursor is to an alert similar to the quote command.
  • Fixed issues with alert/quote commands when there are multiple text selections
2 Likes

v1.4.1

The plugin has been updated to add inline formatting commands for:

  • Highlight: ==text==
  • Strikethrough: ~~text~~
  • Underline: ++text++
  • Superscript: ^text^
  • Subscript: ~text~

They behave as closely as possible to joplin's standard formatting commands for bold/italic, but with improved support for multiline selections