/** * @file Frontmatter extraction: YAML subset, JSON and TOML → plain JSON. * * Frontmatter is detected at the very top of the source only: * * - `---` opens a YAML-subset block, closed by `---` or `...` * - `---json` opens a JSON block, closed by `---` * - `{` (as the first character) opens a JSON object closed by a * line that is exactly `}` * - `+++` opens a TOML block, closed by `+++` * * Whatever the syntax, the result normalizes to one plain JSON value on * the document. The parsers are written from scratch and dependency-free; * an external TOML parser (e.g. `parseToml` from `@jarenjs/josl`) can be * injected through `options.toml` to replace the built-in TOML subset. * * The YAML subset (normative limits in docs/MD-FORMAT.md §3): * scalars (null/booleans/numbers/strings), single- and double-quoted * strings, block maps and sequences by indentation, flow arrays and * maps (multi-line while brackets are open), literal `|` and folded `>` * block scalars with `-` chomping, and `#` comments. No anchors, no * aliases, no tags, no multi-document streams, no complex keys. */ /** Raised for malformed frontmatter inside a detected fence. */ export declare class MdFrontmatterError extends Error { line: number; /** * @param {string} message * @param {number} line 0-based line index inside the frontmatter block */ constructor(message: string, line: number); } /** * Split frontmatter off the top of a Markdown source. * * @param {string} source * @param {{ toml?: (text: string) => any }} [options] * @returns {{ data: any, body: string, lang: 'yaml'|'json'|'toml'|null }} */ export declare function parseFrontmatter(source: string, options?: { toml?: (text: string) => any; }): { data: any; body: string; lang: 'yaml' | 'json' | 'toml' | null; }; /** * Parse the YAML subset into plain JSON. * @param {string} text * @returns {any} */ export declare function parseYamlSubset(text: string): any; export type YamlState = { lines: string[]; pos: number; }; /** * Parse the built-in TOML subset: `[table]` and `[[array-of-tables]]` * headers with dotted paths, bare/quoted/dotted keys, basic and literal * strings, integers (decimal/hex/octal/binary, `_` separators), floats, * booleans, single- or multi-line flow arrays, inline tables, and `#` * comments. Datetimes are kept as strings; multi-line strings are not * supported (normative limits in docs/MD-FORMAT.md §3.3). * @param {string} text * @returns {Record} */ export declare function parseTomlSubset(text: string): Record;