export type MarkdocTagKind = 'tag-open' | 'tag-close' | 'tag-self-closing' | 'annotation' | 'variable' | 'function'; export type MarkdocValueKind = 'string' | 'number' | 'boolean' | 'null' | 'array' | 'object' | 'variable' | 'function' | 'bareword'; export interface MarkdocAttribute { name: string; valueKind: MarkdocValueKind; /** Literal value for string/number/boolean/null; raw source text otherwise. */ value: string | number | boolean | null; /** 0-based offsets into the SPAN text, for child-token synthesis. */ nameStart: number; nameEnd: number; valueStart: number; valueEnd: number; } /** * A class (`.foo`) or id (`#bar`) shortcut inside a named tag's attribute list. * Markdoc folds these into `class`/`id` attributes on the AST node; this parser * keeps them in their own list instead, because a shortcut has no `name=value` * source text and a pseudo attribute entry would carry lying offsets. Folding * them into `class`/`id` is a schema-aware concern, not this parser's. */ export interface MarkdocShortcut { kind: 'class' | 'id'; name: string; start: number; end: number; } export interface ParsedMarkdocSpan { kind: MarkdocTagKind | 'malformed'; name: string | null; attributes: MarkdocAttribute[]; nameStart: number; nameEnd: number; /** Markdoc's positional value slot right after the tag name ({% if $flag %}). * Real Markdoc assigns it to the schema attribute literally named `primary`. */ primary?: { valueKind: MarkdocValueKind; value: string | number | boolean | null; valueStart: number; valueEnd: number; }; /** * Class/id shortcuts from a NAMED tag's attribute list, in source order. * Absent (not an empty array) when none were found. */ shortcuts?: MarkdocShortcut[]; reason?: string; /** * `malformed` only, and only when the scanner knew where it gave up: the * 0-based span offset of the offending character. Kept as a number rather * than baked into `reason` so a consumer can translate it into an absolute * document position. Absent for causes with no single meaningful position, * such as an empty body or a missing delimiter. */ reasonOffset?: number; } /** * Parses one Markdoc `{% ... %}` span's text into its kind, name, * attributes, and offsets. `spanText` is expected to be exactly the span * (e.g. as recognized by the tokenizer) -- offsets in the result are * 0-based indexes into this same string. Never throws; unparseable input * comes back as `{ kind: 'malformed', reason }`. */ export declare function parseMarkdocSpan(spanText: string): ParsedMarkdocSpan; //# sourceMappingURL=span.d.ts.map