import type { Plugin, Processor } from 'unified'; import { type FormulaConfig } from '../Config/formulaConfig'; import { type MarkdownRemarkPlugin, type MarkdownToHtmlConfig } from '../MarkdownEditor/editor/utils/markdownToHtml'; import { type StreamingTokenState } from './streaming/rehypeStreamingTokens'; /** * 构建 markdown → mdast → hast 的 unified 处理器。 * * 内置插件链(顺序敏感): * 1. `remarkParse` - markdown 字符串 → mdast * 2. `remarkGfm` - GFM 扩展(表格、删除线、任务列表、脚注) * 3. `fixStrongWithSpecialChars` - 修复 `**xxx**` 内含特殊字符的解析 * 4. `convertParagraphToImage` - 段落仅含图片时升级为图片块 * 5. `protectJinjaDollarInText` - 保护 Jinja 模板中的 `$` 不被 math 误识别 * 6. `remarkMath` - 行内/块级数学公式识别 * 7. `remarkFrontmatter` - yaml frontmatter 识别 * 8. `remarkDirectiveContainersOnly` + `remarkDirectiveContainer` - `:::` 容器指令 * 9. `remarkChartFromComment` - HTML 注释 + 表格 → chart 代码块 * 10. `remarkRehype` - mdast → hast(保留原始 HTML) * 11. `rehypeRaw` - 处理 hast 中的原始 HTML 字符串 * 12. `rehypeSanitizeUserHtml` - 安全过滤用户 HTML * 13. `rehypeKatex` - 数学公式 → KaTeX * 14. `rehypeFootnoteRef` - 裸 `[^N]` → fnc span(无底部定义场景) * * 之后追加用户自定义的 `extraRemarkPlugins` 与 `config.markedConfig`。 */ export declare const createHastProcessor: (extraRemarkPlugins?: MarkdownRemarkPlugin[], config?: MarkdownToHtmlConfig, formulaConfig?: FormulaConfig, extraRehypePlugins?: Plugin[], streamingTokenState?: StreamingTokenState) => Processor;