Heading

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

interface

interface Heading

An ATX (# Title) or setext (Title underlined with = or -) heading.

Example: Usage

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

const node: Heading = { type: "heading", depth: 2, id: "usage", children: [{ type: "text", value: "Usage" }] };
assertEquals(node.depth, 2);

Properties

type

type: "heading"

Node type.

depth

depth: 1 | 2 | 3 | 4 | 5 | 6

The heading level, from 1 to 6.

id

id: string

The heading's id, for links such as #install. parse() makes it from the heading's plain text with ParseOptions.slugger (GitHub's algorithm by default), unique within the document: the second Install heading gets install-1, the third install-2. It can be empty when the text has no characters the slugger keeps.

children

children: PhrasingContent[]

The heading content.

Source