Skip to content

API 参考 ​

GB/T 7714 Parser 提供以下主要 API:

API说明
parse解析单条参考文献
parseAll批量解析参考文献
validate校验文献格式
format格式化输出
parseCitation解析正文引用标注
formatCitation格式化引用标注

导入方式 ​

typescript
// 命名导入
import { parse, format, validate, parseCitation } from 'gb7714-parser';

// 类型导入
import type { ReferenceUnion, Journal, Book } from 'gb7714-parser';

类型系统 ​

所有文献类型都继承自 Reference 基接口:

typescript
interface Reference {
  type: ReferenceType;
  authors?: Author[];
  title?: string;
  year?: string;
  pid?: string;
  url?: string;
  accessDate?: string;
  mediaType?: MediaType;
  // ... 更多字段
}

特定类型的字段通过接口扩展添加:

typescript
interface Journal extends Reference {
  type: 'J';
  journalTitle?: string;
  volume?: string;
  issue?: string;
  pages?: string;
}

interface Book extends Reference {
  type: 'M';
  publisherPlace?: string;
  publisher?: string;
  version?: string;
  pages?: string;
}

下一步 ​

基于 GB/T 7714-2015 和 GB/T 7714-2025 国家标准