/** * Heading styles — `# Title {style="…"}`. A style merges its level * overrides over the heading's level config and, for the *section* it * opens (the blocks and pages from the heading up to the next heading of * the same or a higher level), replaces the running heads, the page * geometry, the body typography and the palette. Like the part and * paragraph-container plans, the section of every content block is * resolved up front by index so the placement loop can rewind freely. */ import type { ContentBlock } from '../parse/index.js'; import type { ResolvedHeadingLevelConfig, ResolvedHeadingStyleConfig, WritingMode } from '../types.js'; import type { ResolvedConfig, VDTBlock } from '../vdt.js'; import type { ChapterTitlePageInfo } from './placeholders.js'; import type { BlockMeasureContext } from './measureContentBlock.js'; /** The `style` attribute of a heading block, when it names a configured * style. */ export declare function headingStyleOf(block: Pick, resolved: ResolvedConfig): ResolvedHeadingStyleConfig | undefined; /** The parsed blocks as a configuration with `headings.inlineMarks: false` * lays them out: every heading's spans set plain (see `plainSpans`), the * text unchanged. A book title's 《》 stay when they are the document's * book-title mark (`cjk.bookTitleMark: 'brackets'`): they are its * punctuation, not a mark. `blocks` itself when marks are on or no * heading carries one. Memoised on the (memoised) parsed array. */ export declare function headingMarksFor(blocks: ContentBlock[], resolved: ResolvedConfig): ContentBlock[]; /** * The parsed blocks with the title of every heading whose number stands * for it (`numberPosition: 'replace'`, on the heading's level or style) * emptied and the heading flagged `numberIsTitle`: the layout prints the * generated number alone, with no separator, and the outline lists it as * the title. Only numbered headings with a template; the source title of * the others stays. `blocks` itself when no heading is concerned; memoised * on the parsed array and the configuration. */ export declare function numberTitlesFor(blocks: ContentBlock[], resolved: ResolvedConfig): ContentBlock[]; /** Whether a heading block advances the numbering counters. */ export declare function headingIsNumbered(block: ContentBlock, resolved: ResolvedConfig): boolean; /** Whether a heading block is listed by `:::toc`: the style's `toc`, which * a `{toc="false"}` / `{toc="true"}` attribute overrides. */ export declare function headingIsListed(block: Pick, resolved: ResolvedConfig): boolean; /** Whether a heading is structural only — prints nothing and takes no * room (`hidden`): its `{hidden="true"}` / `{hidden="false"}` attribute, * else the `hidden` of the level config it renders with (a style's * included). */ export declare function headingIsHidden(block: { attrs?: Record; }, level: Pick | undefined): boolean; /** Per-level lookups with every style's overrides merged in, cached per * resolved config. */ export interface HeadingLevelResolver { /** The level config a heading block renders with. */ forBlock(block: Pick): ResolvedHeadingLevelConfig | undefined; /** The level config for a level and an optional style id. */ forLevel(level: number, styleId?: string): ResolvedHeadingLevelConfig | undefined; } export declare function createHeadingLevelResolver(resolved: ResolvedConfig): HeadingLevelResolver; export interface HeadingSectionPlan { /** Content-block index → the style of the section the block sits in * (the styled heading itself included); `undefined` outside any. */ byBlock: Array; /** Whether any block sits in a styled section. */ any: boolean; } /** Resolve the styled section of every content block: a styled heading * opens one that runs until the next heading of the same or a higher * level — of any level with `sectionEnd: 'heading'` (#1014) — (which * opens its own section, or none) or the next part divider — * a part sits above every heading level, so front matter styled as a * section never runs on into the parts that follow it. */ export declare function planHeadingSections(contentBlocks: readonly ContentBlock[], resolved: ResolvedConfig): HeadingSectionPlan; /** Per page, the styled section in effect: the most recent styled heading * whose section has not been closed by a heading of the same or a higher * level (any level with `sectionEnd: 'heading'`) or by a part divider. Blank parity pages before a section's heading belong to it, like * chapter titles do (`computeChapterTitles`). */ export declare function computeSectionStyles(blocks: readonly VDTBlock[], totalPages: number, pages: readonly ChapterTitlePageInfo[] | undefined, resolved: ResolvedConfig): Array; /** The writing mode content block `blockIdx` is laid out in: its styled * section's layout (which inherits the document's writing mode unless it * sets its own), else the document's. */ export declare function sectionWritingMode(plan: HeadingSectionPlan, resolved: ResolvedConfig, blockIdx: number): WritingMode; /** The resolved config a styled section's pages are laid out with: the * section's page margins and column layout in place of the document's * (page creation reads both), everything else untouched. */ export declare function deriveSectionGeometryConfig(resolved: ResolvedConfig, style: ResolvedHeadingStyleConfig): ResolvedConfig; /** Measurement context for the blocks inside a styled section with a * `bodyStyle`: the part machinery, run on a config whose `parts.bodyStyle` * is the section's. */ export declare function deriveSectionMeasureContext(ctx: BlockMeasureContext, style: ResolvedHeadingStyleConfig): BlockMeasureContext; /** `derivePartResolvedConfig` for a section body style. */ export declare function deriveSectionResolvedConfig(resolved: ResolvedConfig, style: ResolvedHeadingStyleConfig): ResolvedConfig; //# sourceMappingURL=headingStyles.d.ts.map