Annotations

Annotations are the small authored markers that turn plain MDX into structured website content. They define project subpages, stable slugs, summaries, showcased files, and code presentation details without moving that information into route code.

This page collects the building blocks that are useful when writing by hand and when asking agents to produce content. Each section shows the source pattern first, then explains what the rendered page does with it.

Block Framing & Defaults

Block-level presentation annotations control default chrome, line indicators, headers, and overlay controls without requiring a custom component in the MDX file.

Language Label

Code blocks show their current language as a label by default. It does not switch or change the code. Use !no-language to hide it, or !language to enable it explicitly.

export const packageManagers = ['yarn', 'pnpm', 'npm'];
ts

Line Numbers

Non-shell code displays line numbers by default. Shell blocks omit them so short commands stay compact, but !line-numbers opts an individual shell example back in. Use !no-line-numbers to opt out of the default on any language.

const managers = [
'yarn',
'pnpm',
'npm',
];
ts

Copy Button

Shell blocks show a copy button by default, while non-shell blocks keep copy buttons opt-in. Use !copy to enable copying, or !no-copy to hide it.

// !copy
export const packageManagers = ['yarn', 'pnpm', 'npm'];
ts

When !copy is present alongside the language label, both share the same overlay rail.

Shell Prefix

The project runs through the repository's Yarn and Moon tasks. Shell blocks show the $ prefix and a copy button by default. Use !no-shell-prompt or !no-copy when a shell block should not show either one, or use !shell-prompt and !copy to add them to another code language.

yarn moon run website:build
sh

File Names

Plain fence metadata is rendered as a file name above the code block.

package-manager.ts
```ts package-manager.ts
export const packageManagers = ['yarn', 'pnpm', 'npm'];
```
mdx

Visual & Line Annotations

Annotations can draw attention to a specific part of an example or adjust line presentation without changing the code readers can copy.

Marked Code

!mark highlights the next line. Add a range or regular expression to mark only part of a line, and add a color after the selector to override the theme accent.

function publish(version: string) {
// !mark blue
assertCleanWorkingTree();
// !mark[/version/] gold
return createRelease(version);
}
ts

Diffs

!diff + and !diff - identify inserted and removed lines. Diff styling reuses the mark annotation so both features retain the same visual structure.

Use !noop before an annotation marker to show that marker as code instead of interpreting it. The noop prefix is omitted from the rendered line.

export function packageCommand(manager: string) {
// !diff -
return `${manager} install`;
// !diff +
return manager === 'npm' ? 'npm install' : `${manager} add`;
}
ts

Folded Details

!fold replaces matching inline content with an expandable ellipsis. The native disclosure keeps the full text in the server-rendered document and remains expandable without JavaScript.

// !fold[/className="(.*?)"/gm]
export function Status() {
return <span className="status status--ready">Ready</span>;
}
tsx

Word Wrapping

!word-wrap keeps long lines inside the available width and aligns wrapped text with the original indentation.

// !word-wrap
const command = createPackageManagerCommand({ manager: 'yarn', operation: 'exec', package: 'typescript', executable: 'tsc', arguments: ['--watch', '--preserveWatchOutput'] });
ts

Complex Components

Some authoring patterns need more than a single markdown element. These components keep the MDX source readable while letting the rendered page group related examples, controls, or comparisons into one block.

Code Tabs

Related code blocks that describe one change across several files belong together rather than stacked one after another.

<CodeWithTabs>
```ts !!tabs component.tsx
export function Example() {
return <p>Example</p>;
}
```
```ts !!tabs component.css.ts
export const exampleStyle = style({
display: 'block',
});
```
</CodeWithTabs>
mdx

Package Manager Commands

The !package annotation describes a package-manager-neutral command and renders the matching Yarn, pnpm, and npm forms as tabs.

Install packages

yarn add typescript zod
sh
```sh !package install typescript zod
```
md

Each variant adds the same two packages to the current project and passes their names through unchanged. Only the command differs: Yarn and pnpm distinguish adding a dependency from installing the project, so they use add, while npm overloads install.

Scaffold a project with a one-off package

yarn dlx create-vite my-app --template react-ts
sh
```sh !package exec create-vite my-app --template react-ts
```
md

Here the binary and the package share a name, so no package needs to be declared. The project name and template arguments are identical everywhere, and only the runner changes: yarn dlx, pnpm dlx, and npx.

Run a binary from a named package

yarn dlx -p typescript tsc --watch
sh
```sh !package exec --package typescript tsc --watch
```
md

When the binary does not match the package that supplies it, the package has to be named explicitly. The runners differ as above, and so does the flag: Yarn spells it -p, while pnpm and npm both use --package.

Built and maintained by Sabin Marcu

(2025 -2026)

Table of contents

Experiments