/** Parses Markdown code fences and identifies positions where text can be split safely. */ /** * Represents a fenced code block span in the text. */ export type FenceSpan = { /** Start offset of the fence in the text */ start: number; /** End offset of the fence in the text */ end: number; /** The opening line of the fence (e.g., "```typescript") */ openLine: string; /** The marker characters (e.g., "```" or "~~~") */ marker: string; /** Leading whitespace/indent before the marker */ indent: string; }; type OpenFence = { start: number; markerChar: string; markerLen: number; openLine: string; marker: string; indent: string; }; /** * Resumable line scan behind {@link parseFenceSpans}. `spans` holds the * fences closed so far; `open` is the fence still open at `offset`, the start * of the next unscanned line. Scanning a prefix yields exactly the spans a * full parse reports for that prefix, because fence state depends only on * earlier lines. */ export type FenceScan = { spans: FenceSpan[]; open: OpenFence | undefined; offset: number; done: boolean; }; export declare function startFenceScan(): FenceScan; /** Scan every line of `buffer` that starts at or before `lastLineStart`. */ export declare function advanceFenceScan(buffer: string, scan: FenceScan, lastLineStart: number): void; /** * Parse all fenced code block spans from a string. * * Handles both backtick (```) and tilde (~~~) fences, * with proper matching of closing markers. * * @param buffer - The text to parse * @returns Array of fence spans found, ordered and non-overlapping */ export declare function parseFenceSpans(buffer: string): FenceSpan[]; /** * Find the fence span strictly containing `index` (`start < index < end`). * `spans` must be ordered and non-overlapping, as {@link parseFenceSpans} * returns them. */ export declare function findFenceSpanAt(spans: readonly FenceSpan[], index: number): FenceSpan | undefined; /** * Check if it's safe to break text at a given index (not inside a fence). * * @param spans - Array of fence spans * @param index - Position to check * @returns True if safe to break (not inside a fence) */ export declare function isSafeFenceBreak(spans: readonly FenceSpan[], index: number): boolean; /** Removes an optional whole-value Markdown code fence with a linear delimiter scan. */ export declare function unwrapWholeCodeFence(value: string, languages: readonly string[]): string | null; export {};