/** * THE frontmatter parser — an indentation-aware, `Result`-returning reader of * the YAML subset SharkCraft's Markdown documents use. Round 15 moved it down * from `@shrkcrft/generator` (where it read `spec.md`) so the Markdown * knowledge loader reads frontmatter through the SAME authority; the generator * re-exports it. The round-15 follow-up (F6) moved the last two ad-hoc readers * onto it — decision records (`sharkcraft/decisions/*.md`, `docs/adr/*.md`) and * Cursor `.mdc` rules — through {@link splitFrontmatter} and the `Text` scalar * mode; there is no other frontmatter parser in `packages/*\/src`. * * Supports: * - `key: scalar` (string / number / boolean / null), `# comments`; * - `key: [a, "b"]` inline scalar lists; * - `key: |` (also `|-` / `|+`) literal block scalars, and `key: >` (also * `>-` / `>+`) folded ones (lines joined by a space, a blank line kept); * - `key:` + ` - item` — a list of scalars — or `- item` at the key's own * column (YAML's compact sequence); * - `key:` + ` - k: v` blocks — a list of maps with scalar, scalar-list or * one-level-map values; * - `key:` + ` subkey: value` — a one-level nested map. * * An indented line only ever belongs to the key above it — it can never set a * top-level field (the Markdown loader's old line splitter let ` id: x` under * any block overwrite the entry's id). Quoted strings: `'…'` and `"…"` (`\n`, * `\t`, `\\`, `\"` escapes). Out-of-grammar input is an `INVALID_INPUT` error * naming the 1-based line (plus {@link IParseFrontmatterOptions.lineOffset}). * * {@link IParseFrontmatterOptions.scalars} picks how an UNQUOTED value reads: * `Typed` (default — YAML numbers / booleans / null, a ` # …` tail is a * comment) or `Text` (verbatim: `0001`, `true`, `Fix #12` stay as written; only * a value wholly enclosed in one pair of quotes is unquoted, and only one whose * opening `[` closes at its end is a flow list — `[RFC] Adopt [Bun]` is text). * The grammar — keys, lists, maps, block scalars — is the same in both. * * {@link IParseFrontmatterOptions.keys} names the top-level keys a reader * reads: every other key's block is skipped unparsed, so YAML the parser does * not speak under a key nobody reads can never fail the read. * * {@link IParseFrontmatterOptions.listKeys} names the top-level keys a reader * reads as lists: an inline `[…]` under any other key is that key's one value * (`title: [WIP]` reads `[WIP]`), never a flow list. * * One quirk is deliberate (kept from the spec parser): a list item holding an * unquoted `:` is a MAP — `- file:src/a.ts` reads `{ file: 'src/a.ts' }` — and * a list holds plain values or maps, never both. * * Pure. No IO. */ import { type AppError } from '../result/errors.js'; import { type Result } from '../result/result.js'; import type { FrontmatterScalar } from './frontmatter-scalar.js'; import type { FrontmatterValue } from './frontmatter-value.js'; import type { IParseFrontmatterOptions } from './i-parse-frontmatter-options.js'; export declare function parseFrontmatter(raw: string, options?: IParseFrontmatterOptions): Result>, AppError>; /** * Parse one inline value (`42`, `true`, `"a: b"`, `[a, b]`, a bare string). * `line` names it in an error; `options.scalars` picks the scalar reading * ({@link FrontmatterScalarMode}). */ export declare function parseInlineScalar(s: string, line: number, options?: IParseFrontmatterOptions): Result; //# sourceMappingURL=parse-frontmatter.d.ts.map