interface CleanOptions { /** Strip tracking query parameters (utm_*, fbclid, gclid, etc.) from URLs */ urls?: boolean; /** Strip fragment-only links that don't match any heading in the output */ fragments?: boolean; /** Strip links with meaningless hrefs (#, javascript:void(0)) → plain text */ emptyLinks?: boolean; /** Collapse 3+ consecutive blank lines to 2 */ blankLines?: boolean; /** Strip links where text equals URL: [https://x.com](https://x.com) → https://x.com */ redundantLinks?: boolean; /** Strip self-referencing heading anchors: ## [Title](#title) → ## Title */ selfLinkHeadings?: boolean; /** Strip images with no alt text (decorative/tracking pixels) */ emptyImages?: boolean; /** Drop links that produce no visible text: [](url) → nothing */ emptyLinkText?: boolean; } interface ExtractedElement { selector: string; tagName: string; textContent: string; attributes: Record; } interface FrontmatterConfig { additionalFields?: Record; metaFields?: string[]; /** Callback to receive structured frontmatter data after conversion */ onExtract?: (frontmatter: Record) => void; } interface TagOverride { enter?: string; exit?: string; spacing?: number[]; isInline?: boolean; isSelfClosing?: boolean; collapsesInnerWhiteSpace?: boolean; alias?: string; } interface MdreamOptions { /** Origin URL for resolving relative image paths and internal links. */ origin?: string; /** * Clean up the markdown output. Pass `true` for all cleanup or an object * to enable specific features. `clean.urls` is handled during conversion; * other options are post-processing steps (sync API only). */ clean?: boolean | CleanOptions; /** Enable minimal preset (frontmatter, isolateMain, tailwind, filter). Default: false */ minimal?: boolean; /** * Extract frontmatter from HTML head. * - `true`: enable with defaults * - `(fm) => void`: enable and receive structured data via callback * - `FrontmatterConfig`: enable with config options and optional callback */ frontmatter?: boolean | ((frontmatter: Record) => void) | FrontmatterConfig; /** Isolate main content area. Default when minimal: true */ isolateMain?: boolean; /** Convert Tailwind utility classes. Default when minimal: true */ tailwind?: boolean; /** Filter elements. Default when minimal: excludes form, nav, footer, etc. */ filter?: { include?: string[]; exclude?: string[]; processChildren?: boolean; }; /** Extract elements matching CSS selectors */ extraction?: Record void>; /** Tag overrides. String values act as aliases */ tagOverrides?: Record; /** * Hard-wrap prose at this many characters, breaking on word boundaries. * Applied inline during conversion (zero-cost when unset). Code blocks, * tables, and headings are never wrapped. `0` disables wrapping. */ wrapWidth?: number; /** * Output format. Defaults to `markdown`; use `text` to omit Markdown/HTML * markup while preserving readable text and block spacing. */ format?: 'markdown' | 'text'; } /** * Initialize the mdream web worker. Must be called before htmlToMarkdown. * @param wasmUrl - URL to the mdream_edge_bg.wasm file */ declare function initWorker(wasmUrl: string): Promise; /** * Convert HTML to markdown using the web worker. * Call initWorker() first. */ declare function htmlToMarkdown(html: string, options?: Partial): Promise; /** * Terminate the web worker and free resources. */ declare function terminateWorker(): void; export { htmlToMarkdown, initWorker, terminateWorker };