/** * Core web clipper for converting web pages to markdown. * * @file Implements multiple extraction strategies for different types of web content * * @category Core */ /** * Extraction strategies for different types of content. * * @category Core */ export type ExtractionStrategy = "auto" | "readability" | "manual" | "full" | "structured" | "headless"; /** * Image handling strategies. * * @category Core */ type ImageStrategy = "skip" | "link-only" | "download" | "base64"; /** * Options for web clipping operations. * * @category Core */ export interface WebClipperOptions { /** Extraction strategy to use */ strategy?: ExtractionStrategy; /** How to handle images */ imageStrategy?: ImageStrategy; /** Directory to save downloaded images */ imageDir?: string; /** Custom CSS selectors for manual extraction */ selectors?: string[]; /** Include metadata in frontmatter */ includeFrontmatter?: boolean; /** Request timeout in milliseconds */ timeout?: number; /** Custom User-Agent string */ userAgent?: string; /** Custom HTTP headers */ headers?: Record; /** Path to cookies file */ cookiesFile?: string; /** Follow redirects */ followRedirects?: boolean; /** Maximum redirects to follow */ maxRedirects?: number; /** Show detailed output */ verbose?: boolean; /** Show what would be done without doing it */ dryRun?: boolean; } /** * Result of a web clipping operation. * * @category Core */ export interface ClipResult { /** Generated markdown content */ markdown: string; /** Extracted title */ title?: string; /** Extracted author */ author?: string; /** Published date */ publishedDate?: string; /** Description/excerpt */ description?: string; /** Source URL */ sourceUrl: string; /** Extraction strategy used */ strategy: ExtractionStrategy; /** Images found and processed */ images: { originalUrl: string; localPath?: string; alt: string | undefined; processed: boolean; }[]; /** Links found in content */ links: { url: string; text: string; type: "internal" | "external"; }[]; /** Structured data found */ structuredData?: Record; } /** * Core web clipper class with multiple extraction strategies. * * Provides comprehensive web page to markdown conversion with support for different content types, * extraction strategies, and output formats. * * @category Core * * @example * Basic usage * ```typescript * const clipper = new WebClipper({ * strategy: 'readability', * imageStrategy: 'download' * }); * * const result = await clipper.clip('https://example.com/article'); * console.log(result.markdown); * ``` * * @example * Custom extraction * ```typescript * const clipper = new WebClipper({ * strategy: 'manual', * selectors: ['article', '.content', 'main'] * }); * * const result = await clipper.clip('https://docs.example.com'); * ``` */ export declare class WebClipper { private options; private turndown; constructor(options?: WebClipperOptions); /** * Clip a web page to markdown. * * @param url - URL to clip * * @returns Promise resolving to clip result */ clip(url: string): Promise; /** * Fetch HTML content from a URL. * * @private */ private fetchHtml; /** * Determine the best extraction strategy for content. * * @private */ private determineStrategy; /** * Extract content using the specified strategy. * * @private */ private extractContent; /** * Extract content using Mozilla Readability. * * @private */ private extractWithReadability; /** * Extract content using custom selectors. * * @private */ private extractWithSelectors; /** * Extract full page content. * * @private */ private extractFullPage; /** * Extract content using structured data. * * @private */ private extractStructured; /** * Extract title from HTML. * * @private */ private extractTitle; /** * Extract author from HTML. * * @private */ private extractAuthor; /** * Extract published date from HTML. * * @private */ private extractPublishedDate; /** * Extract description from HTML. * * @private */ private extractDescription; /** * Extract images from content. * * @private */ private extractImages; /** * Extract links from content. * * @private */ private extractLinks; /** * Process images according to the image strategy. * * @private */ private processImages; /** * Generate final markdown content. * * @private */ private generateMarkdown; /** * Generate frontmatter for the markdown file. * * @private */ private generateFrontmatter; /** * Configure Turndown service for HTML to Markdown conversion. * * @private */ private configureTurndown; /** * Resolve a URL relative to a base URL. * * @private */ private resolveUrl; /** * Check if a URL is internal to the base domain. * * @private */ private isInternalLink; } export {}; //# sourceMappingURL=web-clipper.d.ts.map