);
};
```
## 错误处理
```typescript
try {
const result = await markdownService.parseMarkdown(markdown);
// 处理成功结果
} catch (error) {
if (error.message.includes('timeout')) {
console.error('解析超时,文档可能过大');
} else if (error.message.includes('Parser not initialized')) {
console.error('解析器初始化失败');
} else {
console.error('解析失败:', error.message);
}
}
```
## 性能优化
### 1. 缓存解析结果
```typescript
const cache = new Map