Plugin: Markdown Alerts and Quotes (i.e. github alerts) [v1.3.0]

Note:
This plugin was created entirely with AI tools

Markdown Alerts

A Joplin plugin that adds support for Github alert syntax in the Markdown Editor and Markdown viewer.

544623760-5cc62d52-9cd3-40f6-97bc-0bf2a51a83f7

Note:
Note that the Rich Text Editor is not supported. Alerts will (sort of) render in the Rich Text Editor, but editing the note in the Rich Text Editor will remove any github alert syntax.

Differences from "Github Alerts" plugin

The rendering of alerts in the markdown viewer is (almost) identical using markdown-it-github-alerts, but this plugin also styles the alerts inside the markdown editor and provides commands to quickly create/toggle alerts and block quotes.

Alert syntax

Alerts, also sometimes known as callouts or admonitions, are a Markdown extension based on the blockquote syntax that you can use to emphasize critical information: Github Alerts Documentation

To add an alert, use a special blockquote line specifying the alert type, followed by the alert information in a standard blockquote. Five types of alerts are available:

> [!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] Alert with a custom title
> This alert uses a custom title

Markdown Editor

Insert or Toggle alert

A command to quickly create an alert (or toggle alert types) is provided via an icon on the editing toolbar, keyboard shortcut (Ctrl + Shift + A by default), and an entry in the Edit menu. This command will either:

  • On an empty line, insert a new alert (> [!NOTE]) and place the cursor after the marker.
  • If the cursor is within an existing alert, toggle through the alert types (Note > Tip > Important > Warning > Caution).
  • If the cursor is inside a regular blockquote, insert an alert title line above it (respecting nesting).
  • If you have a selection, convert the selected paragraphs/lines into an alert (and toggle types if already an alert).

Insert or Toggle blockquote

A command to quickly insert or toggle blockquotes is provided via an icon on the editing toolbar, keyboard shortcut (Ctrl + Shift + . by default), and an entry in the Edit Menu. This command will either:

  • On an empty line, insert > and place the cursor after the marker.
  • With no selection, toggle the current paragraph (or line if no paragraph).
  • With a selection, convert all paragraphs/lines in the selection to blockquotes (paragraph-aware).

The plugin will apply styling to block quotes containing github alert syntax. They will be similar to standard Joplin block quote styling, but with coloring based on the alert type, and the line with the alert syntax will be rendered as a title.

Markdown Viewer

Block quotes containing github alert syntax will be rendered as github style alerts in the markdown viewer using markdown-it-github-alerts.

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