Plugin: Markdown Alerts and Formatting Commands [v1.6.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 (strikethrough/highlight/insert/superscript/subscript)
  • provides auto-complete dropdown for github alert syntax

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

> [!ABSTRACT]
> A summary or overview of the content that follows.

> [!INFO]
> Additional context or background information on a topic.

> [!TODO]
> A task or action item that still needs to be completed.

> [!SUCCESS]
> Confirms that an action or process completed successfully.

> [!QUESTION]
> A question or point requiring clarification or further thought.

> [!FAILURE]
> Indicates something that did not work or a known limitation.

> [!DANGER]
> Critical warning about something that could cause serious harm.

> [!BUG]
> Documents a known issue, defect, or unexpected behavior.

> [!EXAMPLE]
> Illustrates a concept with a concrete example or sample.

> [!QUOTE]
> A notable quotation or reference from an external source.

Examples:

alert examples in markdown editor


alert examples in markdown viewer

2. Codemirror auto-complete for markdown alerts

Typing >! or > [! at the beginning of an empty line will trigger an auto-completion dropdown to finish the alert syntax from the supported alert types.

examples showing auto-completion of alerts

3. Markdown Editor Commands For Block Structures

The plugin adds toolbar buttons and Edit menu commands for:

  • Insert or Toggle alert
  • Insert or Toggle blockquote
  • Clear Markdown formatting in selection

Insert or Toggle alert

Default shortcut: Ctrl + Shift + A

Behavior:

  • On an empty line, insert > [!NOTE] highlight the "NOTE" text so the user can enter the desired alert type.
  • 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

Clear Markdown formatting in selection

Default shortcut: none

Behavior:

  • Works on the current non-empty selection ranges
  • Removes supported markdown and inline HTML formatting syntax
  • Removes GitHub alert marker lines like > [!NOTE] while preserving any custom alert title text
  • Strips headings, blockquotes, ordered/unordered/nested lists, and task list markers back to plain text
  • Converts external markdown links and image embeds to their raw URLs
  • Preserves Joplin resource links and embeds that target :/<32 hex>

block formatting commands example

4. 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: <sup>text</sup> by default, optionally ^text^
  • Subscript: <sub>text</sub> by default, optionally ~text~

Default shortcuts:

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

Command behavior:

  • No active selection: insert the delimiter pair and place the cursor between them
    • If cursor is inside (or adjacent to) existing markdown formatted text:
      • cursor immediately before opening formatting tokens: move cursor inside
      • cursor immediately before ending formatting tokens: move cursor after
      • cursor otherwise inside formatting: remove formatting and select text
  • 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, tables, and horizontal rules are left alone
  • leading and trailing spaces stay outside newly inserted delimiters

Examples:

> - abc test

Highlight becomes:

> - ==abc test==
## Heading

Highlight becomes:

## ==Heading==

inline formatting commands example

Settings

Auto-completion

Enable/Disable alert type autocomplete in the markdown editor (default enabled).

Syntax

Separate syntax settings for the superscript and subscript commands. Both default to inline HTML because Joplin (v3.6 and newer) renders that syntax in both the editor and the viewer.

Toolbar buttons

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

Available toolbar visibility settings:

  • Alert
  • Blockquote
  • Clear Formatting
  • 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. Changing the superscript or subscript syntax setting applies to commands immediately and does not require a restart.

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

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

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

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

v1.4.1

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

  • Highlight: ==text==
  • Strikethrough: ~~text~~
  • Underline: ++text++
  • Superscript: <sup> or ^text^
  • Subscript: <sub> or ~text~

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

v1.4.2

  • feat/change: make superscript/subscript commands use inline html (e.g. <sup>/</sup>) by default (with option to use the markdown formatting), because Joplin (3.6 and newer) can render inline HTML in the editor, but doesn't support rendering the sup/sub markdown syntax in the editor (and the markdown syntax for this is kind of obscure)
  • feat: added command to clear markdown formatting in selection

test9

v1.5.0:

Support additional alert types (thanks to @itsthejoker), the full list is now:

  • NOTE
  • TIP
  • IMPORTANT
  • WARNING
  • CAUTION
  • ABSTRACT
  • INFO
  • TODO
  • SUCCESS
  • QUESTION
  • FAILURE
  • DANGER
  • BUG
  • EXAMPLE
  • QUOTE

v1.6.0

  • improvements to clear markdown formatting command
  • feat: add auto-completion for alerts:

alertcompleteexample

Lovely improvement.

Would it be possible to show the popup dialogue for Alert selection when the toolbar button is pressed, and when the shortcut key is activated?

Easier than typing > [!

If it's not possible or desirable, could the popup to select the Alert type have it's own keybind?

Appreciate your plugins! :glowing_star:

I can look into that, whether its possible could depend on if there are any limitations with codemirror autocomplete or if it could interfere with other aspects of the insert/toggle alert command

currently there is a shorthand for triggering the autocomplete though, if you type just >!

Thanks, >! for the expansion is useful and quick.

It's great to have all the flavours of Alerts, but as the list has gotten a bit longer, using the shortcut key to cycle through the possibilities takes a little more care and attention, the pop-up is a welcome addition :+1:

In v1.6.1 I made the below changes:

  • If auto-completion is enabled, when activating the insert alert command (keyboard shortcut or toolbar icon) on an empty line, it will insert just > [!], place the cursor after the ! and automatically trigger the auto-completion dropdown.
  • Also adjusted the theming so that the svg icon isn't hard to see for the selected auto-complete result with light theme

There were some issues with manually triggering auto-complete conflicting with other plugins, so this behavior was adjusted in v1.6.2: Release v1.6.2 · bwat47/joplin-markdown-alerts · GitHub