Skip to content

配置系统

DocsJS 提供预设配置(Profile)系统,针对不同使用场景优化处理行为。

内置配置

knowledge-base

适用于技术文档,保留高保真格式:

ts
engine.applyProfile("knowledge-base");

特点:

  • 高保真格式保留
  • MathML 支持
  • 表格完整解析

exam-paper

适用于试卷,支持题目提取:

ts
engine.applyProfile("exam-paper");

特点:

  • 严格语义解析
  • 题目自动识别
  • 答案区域标记

enterprise-document

适用于企业文档,强调安全性:

ts
engine.applyProfile("enterprise-document");

特点:

  • 安全优先
  • 合规性检查
  • 内容净化

自定义配置

ts
const customProfile = {
  id: "scientific-paper",
  name: "学术论文处理器",
  parse: {
    features: {
      mathML: true,
      tables: true,
      images: false,
    },
  },
  security: {
    allowedDomains: ["arxiv.org"],
    sanitizerProfile: "fidelity-first",
  },
};

engine.registerProfile(customProfile);
engine.applyProfile("scientific-paper");

配置选项

选项描述默认值
features.mathML数学公式支持true
features.tables表格解析true
features.images图片处理true
security.allowedDomains允许的域名[]
security.sanitizerProfile净化策略"balanced"

基于 MIT 许可发布。