/** * HTML to Markdown conversion utilities * 无依赖的 HTML 到 Markdown 转换工具 */ export interface HtmlToMarkdownOptions { /** 是否保留换行符 */ preserveLineBreaks?: boolean; /** 是否保留 HTML 注释 */ preserveComments?: boolean; /** 图片处理函数 */ imageHandler?: (src: string, alt: string) => string; /** 链接处理函数 */ linkHandler?: (href: string, text: string) => string; } /** * 将 HTML 字符串转换为 Markdown * @param html HTML 字符串 * @param options 转换选项 * @returns Markdown 字符串 */ export declare function htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions): string; /** * 清理 HTML 字符串,移除不必要的空白和换行 */ export declare function cleanHtml(html: string): string; /** * 检测 HTML 是否来自 Microsoft Word / Office 系。命中任意一个特征即视为 Word HTML: * - `` * - Office XML 命名空间 `xmlns:o="urn:schemas-microsoft-com:office..."` * - `` / `` / `` 自定义标签 * - `class="MsoNormal"` 之类的 MSO 类 */ export declare function isWordHtml(html: string): boolean; /** * 清理 Word/Office HTML 里 markdown 转换链不关心的噪声: * - Office 命名空间标签(o:p / w:* / m:* / v:*) * - IE/Word 条件注释(``) * - 内联 mso-* 样式片段 * - Mso* 类名 * - 把 ` ` 还原为普通空格,便于 markdown 解析 */ export declare function cleanWordHtml(html: string): string; /** * 检测字符串是否为 HTML */ export declare function isHtml(text: string): boolean; /** * 从 HTML 中提取纯文本 */ export declare function extractTextFromHtml(html: string): string; /** * 批量转换 HTML 片段为 Markdown */ export declare function batchHtmlToMarkdown(htmlFragments: string[], options?: HtmlToMarkdownOptions): string[];