/** * Interface defining methods for visiting different types of HTML nodes. * Each method corresponds to a specific HTML element type and returns its Markdown representation. */ export interface HTMLNodeVisitor { /** Converts a text node to Markdown */ visitText(node: Text): string; /** Converts an anchor element to Markdown link syntax */ visitLink(node: HTMLAnchorElement): string; /** Converts a header element to Markdown heading syntax */ visitHeader(node: HTMLElement, level: number): string; /** Converts a paragraph element to Markdown */ visitParagraph(node: HTMLElement): string; /** Converts formatting elements (bold, italic, etc.) to Markdown */ visitFormatting(node: HTMLElement): string; /** Converts code elements to Markdown inline code syntax */ visitCode(node: HTMLElement): string; /** Handles generic HTML elements with no specific Markdown conversion */ visitGeneric(node: HTMLElement): string; /** Converts an HTML div element to Markdown format, adding a single newline */ visitDiv(node: HTMLElement): string; /** Converts an HTML br element to a newline in Markdown */ visitBr(): string; /** Converts a table row element to Markdown */ visitTableRow(node: HTMLTableRowElement): string; /** Converts an HTML table element to Markdown table format */ visitTable(node: HTMLTableElement): string; /** Convert img tag to Markdown image format */ visitImage(node: HTMLImageElement): string; } /** * Main converter class that implements the visitor interface to convert HTML to Markdown. * Uses the Chain of Responsibility pattern for handling different node types. */ export declare class MarkdownConverter implements HTMLNodeVisitor { private handler; constructor(); /** * Converts a text node to Markdown, escaping special characters. */ visitText(node: Text): string; /** * Converts an HTML anchor element to Markdown link syntax. */ visitLink(node: HTMLAnchorElement): string; /** * Converts an HTML heading element to Markdown heading syntax. */ visitHeader(node: HTMLElement, level: number): string; /** * Converts an HTML paragraph to Markdown format. */ visitParagraph(node: HTMLElement): string; /** * Applies Markdown formatting (bold, italic, etc.) to text content. */ visitFormatting(node: HTMLElement): string; /** * Converts HTML code elements to Markdown inline code syntax. */ visitCode(node: HTMLElement): string; /** * Handles generic HTML elements by processing their children. */ visitGeneric(node: HTMLElement): string; /** * Converts an HTML div element to Markdown format, adding a single newline. */ visitDiv(node: HTMLElement): string; /** * Converts an HTML br element to a newline in Markdown. */ visitBr(): string; /** * Converts an HTML table row element to Markdown table row format. */ visitTableRow(node: HTMLTableRowElement): string; /** * Converts an HTML table element to Markdown table format. */ visitTable(node: HTMLTableElement): string; /** * Converts img tag to Markdown image format */ visitImage(node: HTMLImageElement): string; /** * Processes a single node using the handler chain. */ processNode(node: Node): string; /** * Creates and links together handlers in a specific order implementing the Chain of Responsibility pattern. * @returns The first handler in the chain */ private setupHandlerChain; /** * Recursively collects and processes text content from a node and its children. */ private collectTextContent; /** * Collects raw text content from code elements. */ private collectCodeContent; /** * Processes all child nodes of a given node. */ private processChildren; /** * Gets the first handler in the chain. */ private getHandler; }