import type { Dimension, DigitSystem, DocumentMetadata, PostextConfig, ResolvedChipStyleConfig } from '../types.js'; import type { VDTPage } from '../vdt.js'; import { type PageMarks, type PlaceholderResolveOptions, type PlaceholderResult } from '../pipeline/placeholders.js'; /** `'part'` is the opener design of a `:::part` page: it resolves the * heading placeholder set with the part's number and title. */ /** Where a design slot is laid: a running head, a heading's or a part's * design, or a composed page's template decoration (`'composed'`, #855: * the running-head placeholders, with `{attr.x}` read from the page * fence's attributes before the chapter heading's). */ export type DesignContextKind = 'header' | 'footer' | 'heading' | 'part' | 'composed'; /** Heading-specific fields for placeholder resolution. */ export interface HeadingPlaceholderInfo { titleText: string; /** The title as inline Markdown, when the heading sets bold, italic, * superscript or subscript runs (`DefaultOpenerTitle.marked`): what * `{titleText}` prints in a design text element that reads inline marks * (`inlineMarks: true`), so the element sets the heading's runs (#539). * Elements that do not read marks print {@link titleText}. */ titleMarked?: string; /** The document's chip styles, given with a {@link titleMarked} that * holds a heading's chips (`:chip[…]`, #1162): a design text that reads * inline marks sets them as the heading does. Absent otherwise, and a * design text then reads `:chip[…]` as written. */ chipStyles?: readonly ResolvedChipStyleConfig[]; /** Formatted number per the level's `numberingTemplate`, or empty string. */ formattedNumber: string; /** Raw numeric counter for the heading level, if available. */ numericValue?: number; /** Document language of the spelled-out placeholders (`{numberWords}`, * `{numberOrdinalWords}`); English when unset. */ locale?: string; /** The document's digit system, for `{numberDecimal}`; `'latn'` when * unset. */ numerals?: DigitSystem; /** `{chapterNumber}` of the chapter the heading belongs to (its own for a * level-1 heading, else the last level-1 heading's before it) — not the * page's, which is the later chapter where two meet on a page. */ chapterNumber?: string; chapterTitle?: string; /** Heading attributes (`# Title {key="value"}`), for `{attr.}`. */ attrs?: Record; /** In a box style's design (#1014): the box's content as plain text, one * entry per paragraph or list item, for `{boxText}` (all of them, one * per line) and `{boxText.}`. */ boxText?: readonly string[]; } /** What `{leader}` prints in place: a private-use character the layout * of a design text replaces with the leader run (#889, * `design/layout.ts`). Never painted. */ export declare const LEADER_MARK = "\uE0A0"; /** The contents' leader settings (`toc.leader`), for the `{leader}` of a * contents part row (#889). */ export interface DesignLeader { /** Off: the room between the texts stays blank, the page number still * flush with the row's end. */ enabled: boolean; char: string; /** Room kept on either side of the run. */ gap: Dimension; /** The run's own colour, face, size (`em` of the element's) and weight * (#1121); each unset keeps the element's. */ color?: string; fontFamily?: string; fontSize?: Dimension; fontWeight?: number; } export interface DesignPlaceholderContext { kind: DesignContextKind; /** A contents part row (#889): `{leader}` fills the room between the * text before it and the text after it with this leader. Absent * elsewhere, where `{leader}` prints nothing. */ leader?: DesignLeader; page: VDTPage; allPages: VDTPage[]; metadata: DocumentMetadata; chapterTitleByPageIndex: string[]; /** The chapter in force at the top of each page, title and number; back * `{chapterTitleAtTop}` / `{chapterNumberAtTop}` in header and footer * slots (see `computeChapterTitlesAtTop`). */ chapterTitleAtTopByPageIndex?: string[]; chapterNumberAtTopByPageIndex?: string[]; /** Current chapter's H1 attributes per page index; backs `{attr.}` * in header/footer slots (and as a fallback in heading slots). */ chapterAttrsByPageIndex?: Record[]; /** Current part title / number per page index (`{partTitle}` / * `{partNumber}`); see `computePartValues`. */ partTitleByPageIndex?: string[]; partNumberByPageIndex?: string[]; /** Palette overrides of the current part per page index (palette id → * hex): every palette-linked colour of a design slot laid out on that * page takes the part's value. Absent / empty = the document palette. */ partPaletteByPageIndex?: Record[]; /** Current chapter number per page index; backs `{chapterNumber}` in * header/footer slots (heading slots use `heading.chapterNumber`). */ chapterNumberByPageIndex?: string[]; /** Physical pages of the whole book (`{bookTotalPages}`); defaults to * `allPages.length`. */ bookTotalPages?: number; /** The document's digit system: `{totalPages}`, `{bookTotalPages}` and * `{numberDecimal}` are written in it. `'latn'` when unset. */ numerals?: DigitSystem; /** Running marks per key, for `{firstMark.}` / `{lastMark.}` * in header and footer slots (see `computePageMarks`). */ marksFor?: (key: string) => PageMarks | undefined; /** Only present in heading and part contexts. */ heading?: HeadingPlaceholderInfo; /** On a composed page (#984): the counter of the first numbered heading * its frames hold (`{headingNumber}`), and of the one each frame holds * (`{headingNumber.}`), in the document's digits. */ headingNumber?: string; headingNumberByFrame?: Record; /** A composed page's fence attributes (`::::page{template fondo=…}`), * for `{attr.}` in its template's decoration and running heads * (#855). They win over the chapter heading's. */ pageAttrs?: Record; } export declare function allowedPlaceholdersFor(kind: DesignContextKind): Set; /** Whether `name` is a valid placeholder in a slot of the given kind. Covers * the fixed sets above plus the open-ended `attr.` namespace, and — * in running heads (header and footer) — the `firstMark.` / * `lastMark.` marks. */ export declare function isAllowedPlaceholder(name: string, kind: DesignContextKind): boolean; /** Whether any text of `config` names the placeholder `{name}` — a design * slot's element, a heading style's running head… A scan of the whole * configuration, for hosts deciding what a layout needs (the book's page * count for `{bookTotalPages}`); cache it per configuration when calling * it often. */ export declare function configUsesPlaceholder(config: PostextConfig | undefined, name: string): boolean; /** Resolve placeholders for a design slot. The header/footer context * reuses the legacy resolver (same placeholder set). Heading and part * contexts use the extended heading-aware resolver. */ export declare function resolveDesignPlaceholders(template: string, ctx: DesignPlaceholderContext, options?: PlaceholderResolveOptions): PlaceholderResult; /** The `\n` escape: the two characters backslash + n, which is how a design * template or a heading attribute value writes a line break. */ export declare function unescapeLineBreaks(text: string): string; /** The resource id a design image element draws: its `resourceId` with * the placeholders a design text takes filled in — `{attr.}` for an * id the heading (or part, or the page's chapter) names, so one design * serves every chapter with its own picture. A fixed id is returned as * written; an empty result draws nothing. */ export declare function resolveDesignResourceId(template: string, ctx: DesignPlaceholderContext): string; /** The text a design text element prints, before any case transform: its * placeholders filled in, and the `\n` escape turned into a newline in the * element's own template and in `{attr.}` values. Text a placeholder * mirrors from the document (a title, a frontmatter value) is printed as * written, so a code span holding `\n` stays on its line; its real * newlines (a `\\` title break) still start new lines. */ export declare function resolveDesignText(template: string, ctx: DesignPlaceholderContext, /** The element reads inline marks: `{titleText}` is the marked title of * a heading that has one (see {@link HeadingPlaceholderInfo.titleMarked}). */ inlineMarks?: boolean): string; //# sourceMappingURL=placeholders.d.ts.map