SelfscribeDownloadOpen the app

Admonitions

Note, tip, info, warning and danger boxes, each in its own colour, from three colons and a word.

A rulebook. Save it in the app's library, then start any document with use admonitions.

Edit it in the playgroundRead the file

What it shows

Describe a family of boxes with one shared look and a colour for each kind.

What you learn

A palette with dark shades, a class every box shares, one block rule per kind, a colour and a symbol passed as custom properties, a title line that takes its box's colour.

Try this

  • Change the colour of note below, and every note box follows, dark pages included.
examples/rulebooks/admonitions.self · 87 lines
~~~ selfscribe
# Admonitions: coloured callout boxes in five kinds, on top of Markdown. Use it with:  use admonitions
# Lesson: Describe a family of boxes with one shared look and a colour for each kind.
# You learn: a palette with dark shades, a class every box shares, one block rule per kind, a colour and a symbol passed as custom properties, a title line that takes its box's colour.
# Try this: change the colour of `note` below, and every note box follows, dark pages included.
# summary: Note, tip, info, warning and danger boxes, each in its own colour, from three colons and a word.
# category: syntax
set title Admonitions

# ---- Markdown for headings, steps and the rest ------------------------------------------
use markdown

# ---- Colours: one per kind, each with its shade for dark pages ------------------------
palette
  note     #3d6fd8  dark #7fa8ff
  tip      #2b8a3e  dark #69db7c
  info     #0b7f86  dark #3bc9db
  warning  #d9480f  dark #ffa94d
  danger   #c92a2a  dark #ff8787

# ---- "::: kind", the text, then ":::" on its own line: a box in that kind's colour -------
# The class holds the look every box shares. Each rule only says which colour --kind is,
# and which symbol --icon is.
class adm  { margin: 1.1em 0; padding: 0.85em 1.15em; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--kind) 26%, transparent); border-left: 4px solid var(--kind); background: color-mix(in srgb, var(--kind) 8%, transparent) }
class adm > p:last-child  { margin-bottom: 0 }
block  ::: note ... :::     -> aside.adm  { --kind: var(--note); --icon: "✎" }     as adm-note
block  ::: tip ... :::      -> aside.adm  { --kind: var(--tip); --icon: "✓" }      as adm-tip
block  ::: info ... :::     -> aside.adm  { --kind: var(--info); --icon: "i" }     as adm-info
block  ::: warning ... :::  -> aside.adm  { --kind: var(--warning); --icon: "!" }  as adm-warning
block  ::: danger ... :::   -> aside.adm  { --kind: var(--danger); --icon: "✕" }   as adm-danger

# ---- "!! Title" on its own line: the box's title, in its colour, after its symbol -------
class adm-head  { display: flex; align-items: center; gap: 0.6em; margin-bottom: 0.35em; font: 700 0.8em/1.3 var(--doc-font-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--kind) }
class adm-head::before  { content: var(--icon); display: inline-grid; place-items: center; flex: none; width: 1.7em; height: 1.7em; border-radius: 50%; background: color-mix(in srgb, var(--kind) 18%, transparent); font-size: 0.95em; letter-spacing: 0; text-transform: none }
line   !! _                 -> div.adm-head  as adm-title
~~~
# Bleed a radiator

Ten minutes, one radiator key, and the cold patch at the top of the radiator is gone.

::: info
!! You need
A radiator key, an old cloth and a small bowl. A key costs about £2 at a hardware shop.
:::

::: warning
!! Let it cool first
Turn the heating off and wait half an hour. The water inside can be hot enough to scald.
:::

::: danger
!! If you smell gas
Stop, open the windows and call the gas emergency line. Do not switch anything on or off.
:::

## Step by step

1. Start with the radiator furthest from the boiler, downstairs.
2. Hold the cloth under the valve at the top corner. Turn the key a quarter turn anticlockwise, and air hisses out.
3. Close the valve as soon as water drips, then move on to the next radiator.
4. Turn the heating back on. After twenty minutes, every radiator should be warm from top to bottom.

::: tip
!! Check the pressure afterwards
Look at the boiler's gauge. If it reads below 1 bar, top it up with the filling loop until the needle sits between 1 and 1.5.
:::

::: note
!! Still cold at the top?
Sludge may have settled inside. A heating engineer can flush the system in about half a day.
:::

## How it's made

- Each box is a line with three colons and a kind, the text, then three colons on a line of their own: `::: warning` … `:::`.
- The kind picks the colour from the `palette` at the top. The second colour after `dark` is the one dark pages use.
- Every box shares one look, `class adm`. A kind's rule only sets `--kind` and `--icon`, its colour and its symbol.
- A line that starts with `!!` is the box's title. It takes the colour of the box it sits in.

## Try it yourself

1. Change `note` in the palette to `#6741d9`. The last box turns purple.
2. Change `info` to `tip` on the "You need" box. It turns green, with a tick.
3. Delete the `!!` line of a box. The box keeps its colour and loses its title.
4. Copy the `danger` rule, and write `caution` for `danger` in its pattern and its name. A `::: caution` box now comes out red.

**Next:** *AsciiDoc lite* writes the same boxes as one line each, `NOTE:` and `TIP:`.