/** * Text helpers shared by the engine's write and structural handlers: line-ending * normalization and relative→absolute heading fragment preparation. Kept in * their own module so `engine.ts` and `engine/structural.ts` can share them * without a circular import. */ import { Edit } from "./splice.js"; import { PatchResult, Warning } from "./instructions.js"; export type LineEnding = "\n" | "\r\n"; /** Apply `edits` to `document` and package the result with its `warnings`. */ export declare const splice: (document: string, edits: Edit[], warnings: Warning[]) => PatchResult; /** Re-express `text` using the document's line ending. */ export declare const toLineEnding: (text: string, ending: LineEnding) => string; /** * Normalize an inserted body/section fragment to end with exactly one line * ending (or empty for an empty value), matching the model's invariant that a * non-empty content span ends with a single terminator and the library owns the * blank-line gap that follows. */ export declare const endWithSingleEol: (text: string, ending: LineEnding) => string; /** * Reduce a caller-supplied fragment to trimmed, canonical form: leading blank * lines and all trailing whitespace are dropped, and a non-empty fragment ends * with exactly one line ending. Interior lines — including first-line * indentation — are untouched. This is what makes leading/trailing newlines in * caller content meaningless: separators are the library's job, not a channel * for the caller to steer. */ export declare const canonicalFragment: (text: string, ending: LineEnding) => string; /** * The line ending owed so an insertion at `at` begins at a line start: nothing * at the document start or after an existing line ending, one ending when the * preceding character is flush text (a document whose last line has no * terminator). This is the floor below {@link ownedGaps}' blank-line * separator: a joint that owes no *blank line* — a heading-led fragment, a * body write directly under its marker — still must not begin mid-line. */ export declare const lineStartGap: (document: string, at: number, ending: LineEnding) => string; /** * The blank-line separators the library owes around a block-level fragment * spliced over `range` (a collapsed range for a pure insertion). A non-empty * fragment always ends in a single line ending, so on each side the fragment * must be separated from whatever survives there by a blank line: a document * edge needs nothing, an existing blank line suffices, and flush text gets * exactly the endings required. Separators are only ever added — existing * gap bytes are never rewritten. */ export declare const ownedGaps: (document: string, range: { start: number; end: number; }, ending: LineEnding) => { before: string; after: string; }; /** * Turn a relative heading-bearing fragment into the exact bytes to splice in: * rebase its `#`-levels by `baseline`, re-apply the document's line ending, and * reduce it to canonical form (blank edges trimmed, single terminator). */ export declare const sectionFragment: (value: string, baseline: number, ending: LineEnding) => { text: string; warnings: Warning[]; }; /** * Re-level an already-placed heading fragment by `delta`, preserving its own * trailing structure (no single-eol normalization). Used by move and dissolve * to shift a contiguous subtree's `#`-levels in place. Returns `null` edits * when `delta` is 0. */ export declare const relevelText: (slice: string, delta: number, ending: LineEnding) => { text: string; warnings: Warning[]; }; //# sourceMappingURL=text.d.ts.map