Admonition

import { Admonition } from "jsr:@ende/markdown";

interface

interface Admonition

A GitHub alert, such as > [!NOTE]. Only parsed with the gfm option, from a block quote at the top level of the document whose first line is just the marker ([!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION], in any case) and that has content after it. The marker line isn't part of the children.

Text after the marker on its line, separated by a space, is the admonition's Admonition.title: > [!TIP] Want to type-check only?. That's an extension: GitHub only recognizes the marker alone on its line.

Example: Usage

import type { Admonition } from "@ende/markdown/types";
import { assertEquals } from "@ende/assert";

// > [!WARNING]
// > Back up first.
const node: Admonition = {
  type: "admonition",
  kind: "warning",
  children: [{ type: "paragraph", children: [{ type: "text", value: "Back up first." }] }]
};
assertEquals(node.kind, "warning");

Properties

type

type: "admonition"

Node type.

kind

kind: "note" | "tip" | "important" | "warning" | "caution"

The kind of alert, from the marker, lowercased.

title

title?: PhrasingContent[]

The title written after the marker, if any. It replaces the kind's name (such as "Note") when rendering. It isn't one of the children, so visit() doesn't walk it.

children

children: (BlockContent | DefinitionContent)[]

The blocks after the marker line.

Source