/** * Stage 2: plain text canonicalisation. * * Offsets in the rest of the pipeline are character offsets into the canonical string produced * here, not byte offsets into the raw message. Traceability back to the file is via the owning MIME * part's byte range. That split is deliberate: transfer decoding, charset conversion and line * ending normalisation all change lengths, and maintaining a byte level offset map through three * lossy transforms would be fragile for no practical gain. * * What this module does NOT do is unwrap hard wrapped lines. Unwrapping changes offsets and can * merge a quoted line with a new one, which is exactly the mistake that loses content. Wrapping is * recorded as a per line property and resolved later, in the matching projection only. */ /** A single canonical line with its quote depth stripped out. */ export interface TextLine { /** Zero based index into the line array. */ index: number; /** Character offset of the line start within the canonical text. */ start: number; /** Character offset just past the line content, excluding the newline. */ end: number; /** The line exactly as it appears in the canonical text, including any quote prefix. */ raw: string; /** The line with its quote prefix removed. */ content: string; /** Number of leading quote markers. Zero for unquoted lines. */ depth: number; /** True when the line has no non whitespace content after prefix removal. */ blank: boolean; /** True when this unquoted line was re-attached as the wrapped tail of the quote above it. */ wrapContinuation?: boolean; } export interface CanonicalText { /** Normalised text. All offsets in the pipeline refer to this string. */ text: string; lines: TextLine[]; } export type ReplyStyle = 'none' | 'top' | 'bottom' | 'interleaved' | 'top-and-trailing' | 'quote-only'; export interface QuoteProfile { maxDepth: number; quotedLines: number; totalLines: number; /** Share of non blank lines that carry a quote prefix. */ quotedRatio: number; style: ReplyStyle; /** Non blank unquoted lines before the first quoted line. */ contentBefore: number; /** Non blank unquoted lines between the first and last quoted line. */ contentBetween: number; /** Non blank unquoted lines after the last quoted line. */ contentAfter: number; } /** Split a line into its quote depth and remaining content. */ export declare function splitQuotePrefix(line: string): { depth: number; content: string; }; /** * The canonical string for a decoded plain text body, without the line model. * * Every character offset the extractor reports for a plain text representation (segment source * ranges included) indexes the string this returns, not the input. EmailEngine slices message text * at those offsets to fold quoted history, so it must canonicalise with this exact function; a * private copy that drifts by one character moves the cut. Treat the output as a stable contract: * changing it is a breaking change for any caller that slices offsets. * * A leading BOM is dropped, CRLF and lone CR both become LF, NUL characters are removed, and the * result is NFC normalised so that visually identical text compares equal during history * matching. Nothing else is altered: no trimming, no whitespace collapsing, no unwrapping. */ export declare function canonicalisePlainText(input: string): string; /** * Normalise decoded part text into the canonical form used by every later stage. * * The text is exactly `canonicalisePlainText(input)`; this adds the per line model on top of it. */ export declare function canonicaliseText(input: string): CanonicalText; /** * Describe how quoting is laid out in a plain text body. * * The style categories are positional only. They describe where unquoted content sits relative to * quoted content and make no claim about intent, because a trailing block after a quote is just as * likely to be a signature as a genuine bottom posted answer. Deciding that is the classifier's * job, not this function's. */ export declare function profileQuoting(lines: readonly TextLine[]): QuoteProfile; //# sourceMappingURL=text.d.ts.map