Exchange
Pair a request with its responses using :::exchange, side by side when there is room, with status and method badges read from the block titles.
Exchange
:::exchange pairs the code blocks inside it: the first is a request, the others are its responses. They sit side by side when the container is wide and stack when it is narrow.
Basic Use
1:::exchange[Create a remote]2 3```text title="Request"4POST /v1/remotes5{ "name": "origin", "url": "https://example.com/orbit.git" }6```7 8```json title="201 Created"9{ "name": "origin", "mode": "mirror" }10```11 12```json title="409 Conflict"13{ "error": "remote_exists" }14```15 16:::
1POST /v1/remotes2{ "name": "origin", "url": "https://example.com/orbit.git" }1{ "name": "origin", "mode": "mirror" }1{ "error": "remote_exists" }Titles come from fence meta. An http fence highlights request lines once http is in code.langs; text works without it.
Panes
- The first code block directly inside the exchange is the request pane; every later one is a response pane, stacked in the second column.
- Other Markdown inside (a sentence, a callout) renders above the panes, in source order.
- A
usagefence is a synopsis, not a pane. Code blocks inside a list or a nested directive are not panes either. - Without the stylesheet the exchange reads as its title, then the blocks in order.
Badges
Badges are read from the block titles:
| Title starts with | Badge |
|---|---|
A three-digit status (201 Created) |
A status badge coloured by range: 2xx, 3xx, 4xx, 5xx |
An HTTP method (DELETE /v1/remotes/origin) |
A method badge |
| Anything else, on the request block | The method of the block's first line, when it reads METHOD /path |
The badge wraps the start of the caption, so the caption's text does not change; a method read from the first line is put in front of the title (POST Request). Untitled blocks get no badge.
Attributes
| Attribute | Meaning |
|---|---|
[Title] or title |
A label above the panes. It is not a heading: it never enters the table of contents or the heading ids |
theme |
default, muted, glass or plain (no frame); themes are configured under themes.exchange |
palette |
A palette for the frame and the method badges |
#id |
An anchor for the whole exchange, slugged like generated ids (invalid-id when the value had to change) |
Output
1<div data-directive="exchange" class="vl-md-exchange vl-md-exchange--theme-default" data-panes="3">2 <div class="vl-md-exchange-title">Create a remote</div>3 <div class="vl-md-exchange-body">…</div>4 <div class="vl-md-exchange-panes">5 <div class="vl-md-exchange-pane vl-md-exchange-pane--request" data-exchange-pane="request">…</div>6 <div class="vl-md-exchange-responses">7 <div class="vl-md-exchange-pane vl-md-exchange-pane--response" data-exchange-pane="response">…</div>8 </div>9 </div>10</div>
Badges are span.vl-md-exchange-status--2xx (…--5xx) and span.vl-md-exchange-method--post (and so on) inside the block's caption.
Diagnostics
| Code | When |
|---|---|
exchange-needs-pair |
Fewer than two code blocks directly inside; the exchange still renders what it has |
invalid-id |
An #id that is not lowercase letters, digits and - starting with a letter (it is slugged), or has no letters or digits (it is dropped) |