Behaviour SwRS-MDOKFSTUDIO-MYST-001
Admonitions render as coloured callouts with a title
When a document holds an admonition directive, the extension SHALL render a panel with the title, accent colour, badge and Markdown body of its kind, and a custom, untitled, simple, icon-less, version or Quarto form keeps its own title and decoration.
Step 1 of path 1 in StRS-MDOKFSTUDIO-MYST-015: from “A document holds an admonition directive” to “The admonition is drawn as a panel”.
Scenarios 9
The situations the tests check; open one to read it.
nominalNamed kind shows its default title
Givena document with a `:::{note}` directive and a Markdown body, and one directive for each other named kind written with colon or backtick fences
Whenthe preview renders
Thena panel titled Note holds the rendered body, and each kind is titled by its own directive name and has its own palette action, as the table gives
| Directive | Default title |
|---|---|
| note | Note |
| attention | Attention |
| caution | Caution |
| danger | Danger |
| error | Error |
| hint | Hint |
| important | Important |
| seealso | See Also |
| tip | Tip |
| warning | Warning |
boundaryKind outside the named list
Givena document with an admonition kind outside the named list, or an admonition name that is not registered
Whenthe preview renders
Thenthe panel is titled Admonition, uses the generic Admonition rendering and keeps its body
nominalAccent colour and badge by kind
Givena note, a tip, an important, a warning, a caution and a danger admonition
Whenthe preview renders
Theneach panel has the accent of its kind and a badge in that accent, as the table gives
| Kind | Accent |
|---|---|
| note | blue |
| tip | green |
| important | purple |
| warning | yellow |
| caution | red with an octagon (not the warning yellow) |
| danger | red with a cross |
nominalVersion admonitions
Given`{versionadded} 2.1` with a body, `{versionchanged}` and `{deprecated}` with versions, and a body with emphasis
Whenthe preview renders
Theneach panel has the title and accent of the table, with the given version for X, and the Markdown body follows parsed (the emphasis is rendered)
| Directive | Title | Accent |
|---|---|---|
| `{versionadded}` | Added in version X (for example Added in version 2.1), no trailing colon | green |
| `{versionchanged}` | Changed in version X | yellow |
| `{deprecated}` | Deprecated since version X | red |
nominalCustom admonition title and class
Given`{admonition} A *plain* title` with `:class: tip`, and an `{admonition}` without a `:class:` option
Whenthe preview renders
Thenthe title shows its inline Markdown rendered (emphasised text) and the panel has the tip colour, and the panel without a class keeps the neutral accent
boundaryUntitled admonition takes its title from the first body line
Givenan admonition without a title argument whose body starts with a bold line or a heading
Whenthe preview renders
Thenthe first line becomes the panel title, shown as a title and not as a heading, and the remaining lines form the body
| Body starts with | Panel title |
|---|---|
| `**A bold title**` | A bold title |
| `### Title` | Title |
A GitHub alert (`> [!NOTE]`, `> **Note**`) is not an untitled admonition here: its first body line stays in the body (SwRS-MDOKFSTUDIO-GFM-009).
boundarySimple and icon-less admonitions
Givenan admonition with `:class: simple`, and an admonition with `:icon: false`
Whenthe preview renders
Thenthe first is a plain left-bar callout and the second hides the badge, each option changing only its own decoration
boundaryDropdown admonitions show their state
Givenan admonition with `:class: dropdown`, once closed and once with `:open: true`
Whenthe preview renders and the reader toggles the title
Thena chevron at the right of the title points right while the dropdown is closed and down while it is open, whatever the admonition kind and theme
boundaryQuarto callouts
Givena Quarto callout div such as `::: {.callout-tip}`, once with a leading heading and once without
Whenthe preview renders
Thena simple admonition of that kind is shown, titled with the leading heading, or with the kind's default title when the div has no heading
Implemented in 3
Tested by 9
- test/core/directives/registry.test.tsunit
- test/core/preview/previewStyles.test.tsunit
- test/core/render/alertTitle.test.tsunit
- test/core/render/cardsTabs.test.tsunit
- test/core/render/mystFeatures.test.tsunit
- test/integration/mystBlocksWindow.tsintegration
- test/visual/cardsTabsScenarios.tsvisual
- test/visual/scenarioDefinitions1.tsvisual
- test/visual/scenarioDefinitions2.tsvisual
Replaces
SwRS-MDOKFSTUDIO-CORE-061Render version admonitions superseded superseded by SwRS-MDOKFSTUDIO-MYST-001 Markdown file
SwRS-MDOKFSTUDIO-MYST-002Admonitions take an accent colour and badge by kind superseded superseded by SwRS-MDOKFSTUDIO-MYST-001 Markdown file
SwRS-MDOKFSTUDIO-MYST-004Custom admonitions show their written title and class colour superseded superseded by SwRS-MDOKFSTUDIO-MYST-001 Markdown file
SwRS-MDOKFSTUDIO-MYST-005Untitled admonitions take their title from a leading bold line or heading superseded superseded by SwRS-MDOKFSTUDIO-MYST-001 Markdown file
SwRS-MDOKFSTUDIO-MYST-010Simple and icon-less admonitions drop their decoration superseded superseded by SwRS-MDOKFSTUDIO-MYST-001 Markdown file
SwRS-MDOKFSTUDIO-MYST-011Version admonitions show their version title superseded superseded by SwRS-MDOKFSTUDIO-MYST-001 Markdown file
SwRS-MDOKFSTUDIO-MYST-012Quarto callouts render as simple admonitions superseded superseded by SwRS-MDOKFSTUDIO-MYST-001 Markdown file
SwRS-MDOKFSTUDIO-MYST-087Each admonition kind renders under its own directive name superseded superseded by SwRS-MDOKFSTUDIO-MYST-001 Markdown file