/** * @file The Markdown parser: block structure + inline parsing → AST. * * One pass over the source builds the block tree (a container stack of * blockquotes/lists/items plus one open leaf), buffering each leaf's * raw text; inline parsing runs once per leaf when it closes. Plugin * extension points — fence claims, block rules, inline rules — are * prebuilt tables consulted by indexed lookup in the hot loop * (docs/PLUGINS.md); with no plugins the tables are shared empty maps. * * The same machinery runs batch (`parseMarkdown`) and incrementally * (`createIncrementalParser`): blocks land in the output only when * closed, so the incremental parser can hand out completed top-level * blocks while later chunks are still arriving (docs/LOADER.md §4). */ export type MdNode = import('./ast.js').MdNode; export type MdDocument = import('./ast.js').MdDocument; export type MdParseOptions = { /** * compiled-in plugins (docs/PLUGINS.md) */ plugins?: any[]; /** * GFM tables/strikethrough/task lists (default true) */ gfm?: boolean; /** * detect frontmatter (default true) */ frontmatter?: boolean; /** * injectable TOML frontmatter parser */ toml?: (text: string) => any; /** * recorded in `meta.sourceUrl` */ sourceUrl?: string | null; }; /** * Merge a plugin array into the four dispatch tables (first plugin * wins on every collision). Memoized by array identity so module-level * plugin arrays compile exactly once. * @param {any[] | undefined} plugins */ export declare function buildPluginTables(plugins: any[] | undefined): any; export type InlineCtx = { defs: Map; footnotes?: Map; inlines: Map; gfm: boolean; ctx: any; unresolved?: boolean; deferred?: { node: any; raw: string; }[]; }; /** * The inline parsing context threaded through one document. * @typedef {{ defs: Map, * footnotes?: Map, * inlines: Map, gfm: boolean, ctx: any, * unresolved?: boolean, deferred?: {node: any, raw: string}[] }} InlineCtx */ /** * Parse inline Markdown text into inline AST nodes. * @param {string} src * @param {InlineCtx} ictx * @returns {MdNode[]} */ export declare function parseInlines(src: string, ictx: InlineCtx): MdNode[]; /** * Resolve the buffered raw text of finished blocks into inline * children (paragraphs, headings, table cells, task-list markers). * Runs once per block, after which the `raw` buffers are gone. * @param {MdNode[]} blocks * @param {InlineCtx} ictx */ export declare function finishBlocks(blocks: MdNode[], ictx: InlineCtx): void; /** * Parse Markdown source into an MdDocument (frontmatter + AST). * * @example * parseMarkdown('# Hi').ast * // [{ type: 'heading', depth: 1, children: [{ type: 'text', value: 'Hi' }] }] * * @param {string} source * @param {MdParseOptions} [options] * @returns {MdDocument} */ export declare function parseMarkdown(source: string, options?: MdParseOptions): MdDocument; /** * The incremental parsing core behind `streamMarkdown` (docs/LOADER.md * §4): feed chunks, collect completed top-level blocks per feed, and * flush the tail with `end()`. * * Frontmatter resolves as soon as its closing fence arrives; reference * definitions apply to blocks completed after them (the documented * streaming limitation). * * @param {MdParseOptions} [options] * @returns {{ * feed: (chunk: string) => MdNode[], * end: () => MdDocument, * frontmatter: any, * }} */ export declare function createIncrementalParser(options?: MdParseOptions): { feed: (chunk: string) => MdNode[]; end: () => MdDocument; frontmatter: any; };