/** * Composed pages in the parsed document (#854, DESIGN §3, §4): the content * of each `::::page{template=…}` fence gathered by slot. * * The parser leaves a composed page in the block stream as a * `containerStart` / `containerEnd` pair (`containerName: 'composedPage'`, * the fence on `ContentBlock.composedPage`), its frames as `:::frame` * containers and the slot each block names on `ContentBlock.slot`. * {@link composedPages} reads that stream into one node per page. It is * pure and reads any block array, so the layout (P4) can call it on its own * transformed `contentBlocks` and get indices into them. */ import type { ComposedModuleFence, ContentBlock } from '../parse/types.js'; import type { ComposedPageNode, SourceRange } from './types.js'; /** Heading levels a template frame may `take`. */ export type HeadingTake = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; /** What a template frame may `take`: the first heading of a level, or the * page's contents (`'toc'`, #983). */ export type FrameTake = HeadingTake | 'toc'; /** A composed page as the parser read it: the design's * {@link ComposedPageNode} plus what the slot checks need. */ export interface ParsedComposedPage extends ComposedPageNode { /** Source range of the first `slot="…"` value of each slot. */ slotSources: Record; /** The first heading of each level that names no slot (its block * index), which a frame with `takes` receives. */ firstHeadings: Partial>; /** The `:::toc` of the page that names no slot (#983): the directive, * or, once the contents are expanded into their rows, every row and * the page breaks between parts. A frame with `takes: 'toc'` receives * them. */ tocRows: number[]; /** Every piece of the page that names a slot, in Markdown order * (#1061): a grid that repeats a frame takes each piece as one item. */ pieces: SlotPiece[]; /** The page's `:::module` blocks (#1062), in Markdown order. Their * slotted blocks are in `slots` and `pieces` under scoped names * (`.`); the blocks that name no slot are the module's, * not in `unassigned`. */ modules: ParsedModule[]; /** Modules written inside a module (#1062, `moduleNested`): their blocks * are the outer module's. */ nestedModules: ComposedModuleFence[]; /** Source range of the fence line. */ fence: SourceRange; /** The fence had no closing fence of its length (reported by the * parser as `unclosedContainer`). */ unclosed: boolean; } /** A `:::module` of a composed page (#1062). */ export interface ParsedModule { fence: ComposedModuleFence; /** Its opening and closing markers. */ start: number; end: number; /** Its blocks that name no slot, which go to the module's flow frame. */ unassigned: number[]; /** Its first heading of each level that names no slot, which the * module's `takes` frame receives. */ firstHeadings: Partial>; } /** A piece of a composed page sent to a slot (#1061): a `:::frame{slot}` * container (its blocks, its own markers left out), or any other block or * container that names a slot (markers included). */ export interface SlotPiece { slot: string; /** The `slot="…"` value. */ source: SourceRange; /** Block indices, in order. */ indices: number[]; /** The opening marker of a `:::frame` piece. */ fence?: number; /** Within a `:::frame` piece, the blocks and containers one level down * that name a slot of their own (a frame's blocks stay with it, except * in a grid that repeats both). */ inner: SlotPiece[]; } /** * Every composed page of `blocks`, in order, with its content by slot. * * - The blocks of a `:::frame{slot="x"}` go to slot `x` (the frame's own * markers are left out); a frame without a slot goes to `unassigned`. * - Any other block, or container (markers included), goes to the slot it * names (`# T {slot=…}`, `::resource{… slot=…}`, a fence's `slot=`), * else to `unassigned`. * - Slots keep Markdown order, and so do the indices of each slot: several * pieces with the same slot concatenate. */ export declare function composedPages(blocks: readonly ContentBlock[]): ParsedComposedPage[]; /** The block indices of `page` that a frame with `takes: take` receives * (#983): the first heading of that level, or the page's contents. */ export declare function takenBlocks(page: Pick, take: FrameTake | undefined): readonly number[]; /** The modules `page` lays (#1062), as `resolvePageTemplate` takes them. */ export declare function pageModuleUses(page: Pick): { name: string; template: string; }[]; //# sourceMappingURL=document.d.ts.map