Plugins Callouts

lay out a page @mdsvex/plugin-callouts@0.1.1

Callouts

Callouts: note, tip, important, warning and caution, with a default or custom title

Install

pnpm add -D @mdsvex/plugin-callouts

Turn it on

import { callouts } from '@mdsvex/plugin-callouts';

mdsvex({ plugins: [callouts()] });

What it reads

:::note :::warning[Title]

owns note, tip, important, warning, caution

An example

You write
:::note
Callouts load no JavaScript.
:::

:::warning[Breaking change]
The `layout` option is now `templates`.
:::

You get

Note

Callouts load no JavaScript.

Breaking change

The layout option is now templates.

Build-time preview.

GitHub's five alerts as container directives: :::note, :::tip, :::important, :::warning and :::caution. The bracket text is a custom title, and without it the title is the kind's own, Note or Warning. Anything can go inside, and a callout inside a callout takes more colons on the outside.

::::tip
Run the migrator first.

:::caution[Commit your work]
It rewrites every document.
:::
::::

A callout is a <div role="note"> with its title in a <p>, so it adds no landmark to the page and no heading to the outline or a table of contents. Its kind is never colour alone: the default title names it, and with a custom title the icon, whose shape differs by kind, is an image named after the kind. The component renders at build time and loads no JavaScript, and what is inside stays live. A ?text import reads the title and then the body. A leaf or inline callout warns (not_container).

callouts({ titles: { note: 'Remarque' } }) changes the default title of a kind, for a site in another language. The stylesheet has selectors with no specificity and reads --callout-color and --callout-radius from .callout, and each kind is [data-kind]. callouts({ css: false }) leaves it out and keeps the markup. A note, tip, important, warning or caution from a directives module replaces the plugin's component. It gets kind and title as props, and label and children. The plugin's own is @mdsvex/plugin-callouts/Callout.svelte.

The migrator rewrites > [!NOTE] and the other GitHub alerts as these directives, with text after the marker as the title, and leaves a note at each Obsidian callout it can't.

Options, from its types 2

titles?: Partial<Record<CalloutKind, string>>
The title of a callout written with no label, by kind, for a site in another language, a kind left out keeps its english title
css?: boolean
False leaves the default stylesheet out, the markup and its class names stay the same

Components @mdsvex/plugin-callouts/Callout.svelte

Stylesheet @mdsvex/plugin-callouts/callouts.css, or callouts({ css: false }) for none

Find another plugin · Write your own

mdsvex, markdown with Svelte in it. MIT licence.