Nodes

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

type alias

type Nodes = Root | BlockContent | DefinitionContent | ListItem | TableRow | TableCell | PhrasingContent

Any node, as a union discriminated by type.

Example: Usage

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

function textOf(node: Nodes): string {
  if ("value" in node) return node.value;
  if ("children" in node) return node.children.map(textOf).join("");
  return "";
}

assertEquals(textOf({ type: "strong", children: [{ type: "text", value: "Hi" }] }), "Hi");

Source