Markdown syntax
JAAMD extends CommonMark and
GitHub Flavored Markdown with the blocks
below. Each one is shown as you write it, then as it renders. Every one of them
can be turned off with the
features option.
Alerts
GitHub-style blockquote alerts, in five types: NOTE, TIP, IMPORTANT,
WARNING and CAUTION.
> [!NOTE]
> Useful information the reader should know.
> [!WARNING]
> Urgent information needing immediate attention.
NOTE
Useful information the reader should know.
WARNING
Urgent information needing immediate attention.
As on GitHub, the marker is the first line of the blockquote, alone on it.
> [!NOTE] Some text stays a plain blockquote.
Code tabs
Group several code blocks into a tabbed panel. The text after the language is
the tab label; it falls back to the language, then to Tab N. Annotations
after the label, such as {1,3} or title="app.js", stay on the code block
for the highlighter: bash npm {2} is the tab “npm”.
Text between the code blocks goes in the panel of the block above it, so a tab can carry a note. Text before the first block stays above the tabs.
:::code-tabs
```bash npm
npm install
```
```bash pnpm
pnpm install
```
:::
npm install
pnpm install
Table of contents
A :::toc block wraps the list you write in a navigation landmark. Nothing is
generated: entries, order, wording and depth are whatever the Markdown says.
The text in brackets is an optional title.
:::toc[On this page]
- [Alerts](#alerts)
- [Code tabs](#code-tabs)
:::
A - list loses its bullets, 1. keeps the numbers. Entries are plain anchors
and navigate with JavaScript disabled; with it, the entry whose section is on
screen is marked aria-current="location". The title is a <p>, so it stays
out of getHeadings() and has no anchor.
Writing the anchors
Heading ids come from Astro, slugged with
github-slugger:
| Heading | Anchor |
|---|---|
## Getting started |
#getting-started |
## Details / accordion |
#details--accordion (one dash per space, the / dropped between them) |
## What's new? |
#whats-new (punctuation removed, not replaced) |
## snake_case |
#snake_case (underscores survive) |
a second ## Setup |
#setup-1 |
The client script follows the same rules, so ids match for Markdown that never
went through Astro’s pipeline (set:html, HTML from a CMS).
With a sticky header, raise --jaamd-scroll-margin-top (default 80px).
NOTE
:::toc needs the directive syntax, on by default. With
features: { toc: false } the block degrades to a plain <div>: list and
links intact, unstyled.
Spoilers
Text hidden until the reader activates it, inline or as a block. Spoilers are reachable from the keyboard. Once revealed, a spoiler stays open, and its links and text work as anywhere else; it hides again on reload. Without JavaScript, spoilers are shown.
The answer is :spoiler[42].
:::spoiler
A whole paragraph, hidden.
:::
The answer is 42.
A whole paragraph, hidden.
In HTML you write yourself, the class is jaamd-spoiler.
Details
<details> is plain HTML. JAAMD styles it and animates it open and closed, in
CSS alone.
<details>
<summary>Why is the sky blue?</summary>
Shorter wavelengths scatter more.
</details>
Why is the sky blue?
Shorter wavelengths scatter more.Without writing anything
Some enhancements need no syntax. Every heading gets an anchor link, every code block a copy button, every image a lightbox, and every table a scroll container on narrow screens. See Client script.