import { Element, Root } from 'xast'; /** A pruned document, ready to render as a fragment preview. */ export interface Skeleton { /** The pruned document, serialized. */ content: string; /** `@xml:id` of the division to render; pass as the `subtree` param. */ divisionId: string; /** That division's numbering level; pass as the `subtree-level` param. */ level: number; } /** * A division's numbering level, mirroring `mode="level"` in * pretext-numbers.xsl. `ancestors` runs from the document element down to (and * including) the division itself. * * `hasParts` is upstream's `$b-has-parts` (`boolean($root/book/part)`), which * pushes a book's chapters down a level. */ export declare function divisionLevel(ancestors: Element[], hasParts: boolean): number; /** * Swap the division carrying `id` for `replacement`, in place. Returns false * when the tree holds no such division. * * This is what lets a preview show *unsaved* work: the document on disk * supplies the structure around the fragment, while the fragment itself comes * from the editor's buffer. */ export declare function replaceDivision(tree: Root, id: string, replacement: Element): boolean; /** * Build a skeleton of `tree` that preserves the numbering of the division * carrying `divisionId` and resolves the cross-references it makes. * * Prunes `tree` in place and serializes the result, so the caller can go on to * use the same tree — computing a source map from it, for instance, which is * what the renderer does. * * Returns undefined when the tree holds no such division — an unsaved file * whose `@xml:id` is not yet in the main document, say — which the caller * should treat as "fall back to the standalone fragment wrapper". */ export declare function buildSkeleton(tree: Root, divisionId: string): Skeleton | undefined;