/** * Code listings line by line (#624): a `code` block (a ```` ``` ```` or * `~~~` fence, or indented code) is set one line per source line, as * written. No Knuth–Plass, no hyphenation, no justification, no runt or * tracking levers: every character keeps its advance in the code face, a * run of spaces its width, and a tab goes on to the next multiple of * `codeStyle.tabSize` character cells (a tab segment, `\t`, so copied text * keeps it). A line wider than the measure is turned over, set smaller or * cut (`codeStyle.overflow`). Line numbers stand in a gutter before the * code, out of the text (the page's `lineNumbers` slot, see * {@link buildCodeLineNumbers}). * * The lines are built segment by segment here, not by the paragraph * breaker, which collapses and trims spaces. Each segment carries its face * (`fontString`) and, when a token kind or a highlighter gives one, its * colour; the segments' widths are final, from the line's box (`bbox.x`). */ import type { ContentBlock } from '../parse/index.js'; import type { ResolvedCodeStyleConfig } from '../types.js'; import { type ResolvedConfig, type VDTDocument, type VDTLine, type ContentWarning } from '../vdt.js'; import type { MeasuredBlock } from '../measure/index.js'; /** What a fence asks of its listing, over `codeStyle`. */ export interface CodeFenceSettings { lineNumbers: boolean; /** The first line's number. */ start: number; /** Source lines (1-based, as written) the fence highlights. */ highlight: ReadonlySet; } /** `highlight="3,5-7"`: the line numbers it names (1-based, from the * listing's first line whatever `start` says). */ export declare function highlightLines(value: string | undefined): Set; /** The settings a fence's attributes give its listing. */ export declare function codeFenceSettings(block: ContentBlock, cs: ResolvedCodeStyleConfig): CodeFenceSettings; /** How a listing's lines were fitted, for its warning. */ export interface CodeFit { mode: 'wrap' | 'shrink' | 'clip'; /** Source lines too wide for the measure. */ lines: number; /** The size the listing was set at, as a share of `fontSize` (below 1 * when shrunk). */ scale: number; } export interface MeasuredCode extends MeasuredBlock { /** Set when a line did not fit the measure as written. */ fit?: CodeFit; /** The numbers' look and the room between them and the code, when the * listing is numbered. */ numbers?: { gap: number; fontString: string; color: string; }; /** The size the listing was set at, px (the code size, or less when it * was shrunk). */ fontSizePx: number; } export interface CodeLinesInput { block: ContentBlock; /** The code's size and leading (the listing box's body style). */ fontSizePx: number; lineHeightPx: number; /** The listing's colour (hex). */ color: string; /** The measure, px. */ measure: number; resolved: ResolvedConfig; /** Source offset of the markdown body inside the document. */ bodyOffset: number; /** The frame runs right to left (a mirrored page): the lines keep their * left-to-right order and are set from the frame's far side. */ mirrored?: boolean; } /** Lay a listing out (see the module comment). */ export declare function measureCodeLines(input: CodeLinesInput): MeasuredCode; /** * The line numbers of the listings of `doc` (#624), in each page's * `lineNumbers` slot beside any the margin numbers set there (#621): each * right-aligned against the end of its listing's gutter, on its line's * baseline, an artifact out of the text (the slot's numbers are hidden * from assistive technology, left out of a selection, and painted under an * empty `/ActualText` in a tagged PDF). Vertical pages get none. */ export declare function buildCodeLineNumbers(doc: VDTDocument): void; /** A `codeOverflow` warning for each listing (by content index) one of * whose lines did not fit its measure as written (#624). */ export declare function codeOverflowWarnings(doc: VDTDocument): ContentWarning[]; /** The plain text of a listing's lines as written (a continuation joins * its line, a line feed ends each source line). */ export declare function codeLinesText(lines: readonly VDTLine[]): string; //# sourceMappingURL=codeLines.d.ts.map