/** * Verse line by line (#620): a `:::verse` poem whose lines carry no * hemistich separator (or `layout="lines"` on its fence), set as it is * written. Every source line is a line of verse, a run of blank lines a * stanza break, leading whitespace an indent. * * - Each stanza is a paragraph block of its own (`VerseInfo.stanza`), so a * column or page breaks between stanzas by the paragraph rules, and * inside one by the orphan and widow rules, which then count the * stanza's lines. The space between stanzas is the block's bottom * margin (`stanzaSpace`, one line of the poem's leading by default). * - A line's indent is its leading spaces × `indentStep` (a tab counts * four spaces, an ideographic space two). A stepped line (`+ …`) starts * where the line above ended, a word space on. * - A line a little wider than the measure tightens its word spaces, down * to `bodyText.minWordSpacing` of their natural width (the shrink limit * of justified text), and stays on one line (`tighten`, default on); the * segments carry the tighter spaces, so every renderer paints them. * - A line still wider than the measure turns over: `turnover="hang"` sets the * rest on the line after it, `hang` (the style's `hangingIndent`, else * `bodyText.verse.hang`) in from the line's own start; `turnover="right"` * sets it flush with the end side behind an opening bracket * (`turnoverMark`). Turnovers break at word spaces (and hyphenate only * when the poem's style asks for hyphenation itself). * - `align="center"` (the default in horizontal text) centres the poem as a * block on its longest line, every line flush with the block's start; * `align="start"` (the default in vertical text, where the poem hangs * from the head) sets it flush with the measure's start. * * The lines carry final segment widths and their own `bbox.x` (the block is * set flush left), in the flow frame, as the bayt layout's do * (`pipeline/verse.ts`): every renderer paints them as measured. A poem * whose direction opposes its frame's (a Latin poem in an Arabic book) is * measured from its own start side. */ import type { ContentBlock, InlineSpan } from '../parse/index.js'; import type { DirectiveAttrs } from '../parse/types.js'; import type { ResolvedConfig, VDTLineSegment } from '../vdt.js'; import type { MeasuredBlock, MeasurementCache } from '../measure/index.js'; import type { BlockStyle } from './styles.js'; /** A poem's line-layout settings, read from its fence over * `bodyText.verse`. */ export interface VerseLinesSettings { /** Width of one leading space, px. */ indentStepPx: number; turnover: 'hang' | 'right'; /** Indent of a hanging turnover from its line's start, px. */ hangPx: number; turnoverMark: string; /** Space between two stanzas, px. */ stanzaSpacePx: number; /** Stanzas of this many lines or fewer stay whole; 0: off. */ keepStanzas: number; align: 'center' | 'start'; /** Whether a line too wide for the measure tightens its word spaces * (down to `bodyText.minWordSpacing`) before it turns over. */ tighten: boolean; } /** Whether a stanza block is set line by line: a stanza of the line layout, * unless the fence named no layout and the configuration was stored * before #620 (`bodyText.verse.layout: 'bayt'`), when it is set as single * hemistichs, as postext 1.22 set a poem with no separator. */ export declare function versesLineByLine(raw: ContentBlock, resolved: ResolvedConfig): boolean; /** A poem's settings (see {@link VerseLinesSettings}). */ export declare function verseLinesSettings(attrs: DirectiveAttrs, style: Pick, resolved: ResolvedConfig, vertical: boolean): VerseLinesSettings; /** A stanza's lines of verse: its spans cut at the line feeds. */ export declare function stanzaRows(spans: readonly InlineSpan[]): InlineSpan[][]; export interface VerseLinesInput { /** The stanza, its spans resolved for measuring. */ contentBlock: ContentBlock; /** Every stanza of the poem in order, spans resolved likewise; the * stanza being set among them (at `contentBlock.verse.stanza.index`). */ poem: readonly ContentBlock[]; style: BlockStyle; /** The measure, px. */ measureMaxWidth: number; settings: VerseLinesSettings; /** The poem's direction and its frame's. */ direction: 'ltr' | 'rtl'; frameDirection: 'ltr' | 'rtl'; /** `bodyText.minWordSpacing`: how far a word space may tighten, as a * share of its natural width. */ minWordSpacing: number; cache?: MeasurementCache; } /** A line's word spaces tightened, down to `minWordSpacing` of their * natural width each and in proportion to what each can give, so the * line comes to `excess` px narrower; undefined when they cannot give * that much. Fixed spaces (a `keepSpaces` caesura) are text and never * tighten, nor does a CJK autospace. The segments are copies: the * measured line stays as the cache holds it. */ export declare function tightenedSegments(segments: readonly VDTLineSegment[], excess: number, minWordSpacing: number): { segments: VDTLineSegment[]; ratio: number; } | undefined; /** Lay a stanza out (see the module comment). */ export declare function measureVerseLines(input: VerseLinesInput): MeasuredBlock; //# sourceMappingURL=verseLines.d.ts.map