import { JSDOMDocument } from './document'; /** * Represents the structured content extracted from a web page. */ export interface ReadabilityContent { /** The URL of the original page */ url: string; /** The article title */ title?: string; /** The article content as HTML */ content: string; /** The length of the content in characters */ length?: number; /** A short excerpt from the article */ excerpt?: string; /** The author of the article */ byline?: string; /** The reading direction (ltr or rtl) */ dir?: string; /** The name of the website */ siteName?: string; /** The language of the content */ lang?: string; /** The publication date/time of the article */ publishedTime?: string; } /** * Configuration options for the readability process. */ export interface ReadabilityOptions { /** Whether to enable debug mode */ debug?: boolean; /** Skip image processing */ skipImages?: boolean; } export type CompatDocument = Document | JSDOMDocument; /** * Extracts readable content from a given HTML document. * * @param document - The HTML Document object to process. * @param options - Configuration options for the readability process. * @returns A Promise that resolves to a ReadabilityContent object. * @throws {ReadabilityError} When parsing fails or the document is invalid. * * This function performs the following steps: * 1. Handles lazy-loaded images by setting their src attribute. * 2. Extracts the byline from meta tags. * 3. Processes the document using platform-specific handlers if applicable. * 4. If the platform doesn't require skipping, it uses Mozilla's Readability to parse the content. * 5. Returns the parsed article content or the full HTML content if skipped. * * @example * ```typescript * try { * const document = await getDocument('https://example.com'); * const content = await readability(document); * console.log(content.title); * } catch (error) { * console.error('Extraction failed:', error.message); * } * ``` */ declare function readability(document: CompatDocument, { debug, skipImages }?: ReadabilityOptions): Promise; export { readability };