/** * A markdown document you can pull data out of: frontmatter fields, sections * by heading, fenced code. Markdown is the glue language between humans and * agents, so the accessors are strict: asking for a field or section that is * not there throws rather than returning undefined, which is what lets a * caller treat a document as a data source instead of hand-rolling regexes. */ export declare class Markdown { /** The full source text, verbatim. */ readonly text: string; /** Frontmatter key/values. Empty object when there is no frontmatter. */ readonly fields: Record; /** The text after the frontmatter. */ readonly body: string; /** Every heading in the document, in order, all levels. */ readonly sections: Section[]; private constructor(); static parse(text: string): Markdown; /** First level-1 heading, or null when the document has none. */ get title(): string | null; /** Throws when the field is absent. */ field(name: string): string; has(heading: string): boolean; /** The section under `heading` (case-insensitive). Throws when absent. */ section(heading: string): Section; private find; } /** Thrown when an accessor is asked for something the document does not have. */ export declare class MarkdownError extends Error { } export interface CodeBlock { /** The fence's info string, e.g. "ts". Empty when the fence has none. */ lang: string; code: string; } /** * One heading and everything under it. `body` runs until the next heading of * the same or a higher level, so subsections are included; `lead` stops at the * first child heading, so it is the section's own prose. */ export declare class Section { readonly heading: string; readonly level: number; /** 1-based line of the heading in the source document. */ readonly line: number; readonly body: string; readonly lead: string; constructor(heading: string, level: number, /** 1-based line of the heading in the source document. */ line: number, body: string, lead: string); /** * Fenced code blocks, in `body` (subsections included, the default) or * just this section's own `lead`. */ codeBlocks(scope?: "body" | "lead"): CodeBlock[]; }