📚 API 使用示例
1. 智能渲染(自动选择 AST 或旧版)
// 简单渲染(无注释)
const html = MarkdownIntegration.smartRender(markdown, images);
// 带注释渲染
const annotations = [{ text: 'test', id: 'ann-1' }];
const html = MarkdownIntegration.smartRender(
markdown,
images,
annotations,
'content-id'
);
2. 替代 createCustomMarkdownRenderer
// 旧版(不再工作)
const renderer = createCustomMarkdownRenderer(annotations, 'ocr', ...);
marked(md, { renderer });
// 新版(使用集成层)
const config = MarkdownIntegration.createAnnotationConfig(annotations, 'ocr');
const html = config.render(markdown, images);
3. 批量渲染 tokens
const tokens = marked.lexer(markdown);
const htmlArray = MarkdownIntegration.renderTokens(
tokens,
images,
annotations,
'content-id'
);