/**
* MHTML / MHT container parsing (RCL-01).
*
* An MHTML archive is an RFC 2557 `multipart/related` MIME message: the page
* plus every subresource it referenced, each part carrying its own transfer
* encoding and charset. Chrome's `Page.captureSnapshot` writes them
* quoted-printable; Internet Explorer and most "save as web archive" tools
* write base64.
*
* Only the ROOT frame is prose. Picking the first `text/html` part instead is
* how an ad iframe ends up indexed as the article, so the root is resolved
* from the container's `Snapshot-Content-Location` / `Content-Location` when
* one is present.
*
* Read the file as `latin1` (or pass a Buffer): byte fidelity matters before
* transfer decoding, and the real charset is only known per part.
*
* @module v1/cli/knowledge/mhtml
*/
export interface MhtmlPart {
/** Lowercased MIME type without parameters, e.g. `text/html`. */
contentType: string;
/** Charset from the part's Content-Type, lowercased, or null. */
charset: string | null;
/** Content-Location, or null. */
location: string | null;
/** Lowercased Content-Transfer-Encoding; `binary` when unstated. */
encoding: string;
/** Raw bytes after transfer decoding. */
body: Buffer;
headers: Record;
}
export interface ParsedMhtml {
/** The part holding the page itself, or null when there is no HTML part. */
root: MhtmlPart | null;
parts: MhtmlPart[];
/** Container `Snapshot-Content-Location`/`Content-Location` header. */
snapshotLocation: string | null;
/** Container `Subject` header — Chrome writes the page title here. */
subject: string | null;
}
/** Decode a quoted-printable body to bytes: soft line breaks vanish, `=XX`
* becomes one byte, everything else is its own latin1 byte. */
export declare function decodeQuotedPrintable(input: string): Buffer;
/** Decode bytes under a MIME charset, falling back to UTF-8 (then latin1)
* rather than failing an ingest over an exotic label. */
export declare function decodeCharset(bytes: Buffer, charset: string | null): string;
/**
* Parse an MHTML container. Anything that is not a well-formed multipart
* message is treated as a single part, so a plain `.html` file renamed to
* `.mhtml` still ingests.
*/
export declare function parseMhtml(raw: string | Buffer): ParsedMhtml;
/** Parse a container and return its root frame decoded to a string. */
export declare function mhtmlToHtml(raw: string | Buffer): {
html: string;
location: string | null;
subject: string | null;
};
//# sourceMappingURL=mhtml.d.ts.map