@citestyle/bibtex

中文文档
1.1.0发布于 2026/05/30MITTypeScriptES Module近 30 天下载 2023

BibTeX QQ CSL- JSON 解析器和序列器

中文使用文档
文档目录9 节
  1. 安装
  2. 解析 BibTeX 到 SSL- JSON
  3. 导出 SSL- JSON 到 BibTeX
  4. 全程: BibTeX 到格式化的书目
  5. LaTeX 到 Unicode 转换
  6. API 密码
  7. parseBibtex(str) → CslItem[]
  8. exportBibtex(items) → string
  9. convertLatex(str) → string

@citestyle/bibtex (中文(简体) )

将 BibTeX 文件放入 CSL-JSON 并导出 CSL-JSON 返回 BibTeX 。 处理BibTeX真实世界的混乱: LaTeX口音命令, @string 缩写, # 相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相接相相接相接相接相接相接相接相相相接相接相相接相相相相相相相接相接相接相接相接相相相相相相接相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相相.

使用此选项将 BibTeX 引用带入 Citestyle 格式化管道, 或者导出格式化的 BibTeX 以与 LaTeX 用户共享 .

安装

npm install @citestyle/bibtex

解析 BibTeX 到 SSL- JSON

import { parseBibtex } from '@citestyle/bibtex'

const bibtex = `
@article{smith2024,
  author = {Smith, John and de la Cruz, Maria},
  title = {A Study of {DNA} Replication},
  journal = {Nature},
  year = {2024},
  volume = {620},
  pages = {100--108},
  doi = {10.1038/example}
}
`

const items = parseBibtex(bibtex)

items[0].title                                // "A Study of DNA Replication"
items[0].author[0].family                     // "Smith"
items[0].author[1]['non-dropping-particle']    // "de la"
items[0].page                                 // "100-108"
items[0].DOI                                  // "10.1038/example"

导出 SSL- JSON 到 BibTeX

import { exportBibtex } from '@citestyle/bibtex'

const output = exportBibtex([{
  id: 'smith2024',
  type: 'article-journal',
  title: 'A Study of DNA Replication',
  author: [{ family: 'Smith', given: 'John' }],
  issued: { 'date-parts': [[2024]] },
  'container-title': 'Nature',
  volume: '620',
  page: '100-108',
  DOI: '10.1038/example',
}])

// @article{smith2024,
//   author = {Smith, John},
//   title = {A Study of DNA Replication},
//   journal = {Nature},
//   year = {2024},
//   volume = {620},
//   pages = {100--108},
//   doi = {10.1038/example}
// }

全程: BibTeX 到格式化的书目

import { parseBibtex } from '@citestyle/bibtex'
import { createRegistry } from '@citestyle/registry'
import * as apa from '@citestyle/styles/apa'

const items = parseBibtex(readFileSync('references.bib', 'utf-8'))

const registry = createRegistry(apa)
registry.addItems(items)

const bibliography = registry.getBibliography()
bibliography.forEach(entry => {
  console.log(entry.html)   // Semantic HTML with CSS classes and linked DOIs
  console.log(entry.text)   // Plain text for copy-paste
})

LaTeX 到 Unicode 转换

import { convertLatex } from '@citestyle/bibtex'

convertLatex('Universit\\"at M\\"unchen')   // "Universität München"
convertLatex('Sch\\"onfinkel')               // "Schönfinkel"
convertLatex('{\\ss}')                       // "ß"
convertLatex('\\o')                          // "ø"
convertLatex("Caf\\'e")                      // "Café"

120+ LaTeX口音和命令映射. 封面 \", (中文(简体) ), \', (中文(简体) ), \^, (中文(简体) ), \~, (中文(简体) ), \``, \c, \v, =:, \ H, \u, \d, \b, ưμ㼯a, and special commands (旋转, {\fn黑体\fs22\bord1\shad0\3ahbe\4ah00\fscx67\fscy66\2chffffff\3ch808080}你还好吧, {\FN黑体\FS22\BORD1\SHAD0\3AHBE\4AH00\FSCX67\FSCY66\2CHFFFFFF\3CH808080}我们该走了, \ ae, {\FN黑体\FS22\BORD1\SHAD0\3AHBE\4AH00\FSCX67\FSCY66\2CHFFFFFF\3CH808080}AE 说, \a, \. AA 对, \ l, {\FN黑体\FS22\BORD1\SHAD0\3AHBE\4AH00\FSCX67\FSCY66\2CHFFFFFF\3CH808080}你觉得呢, \, (原始内容存档于2018-10-21) (中文(简体) ).

API 密码

parseBibtex(str) → CslItem[]

将 BibTeX 字符串分析为 SSL- JSON 项 .

支持的条目类型数字 : @article, (中文(简体) ), @book, (中文(简体) ), @inproceedings, (中文(简体) ), @incollection, (中文(简体) ), @inbook, (中文(简体) ), @phdthesis, (中文(简体) ), @mastersthesis, (中文(简体) ), @misc, (中文(简体) ), @techreport, (中文(简体) ), @unpublished, (中文(简体) ), @proceedings, (中文(简体) ), @manual, (中文(简体) ), @conference, (中文(简体) ), @booklet, (中文(简体) ), @online

处理数字 :

  • LaTeX口音和命令转换(120+映射)
  • @string 缩略语扩展和 # 协和
  • 被压缩和引用的字符串值、 嵌入式套接字
  • 月份缩写jan– 说吧 –dec(中文(简体) )
  • 用粒子解析名称( N)von, (中文(简体) ), de, (中文(简体) ), de la)并后缀(Jr., (中文(简体) ), III(中文(简体) )
  • 公司/机构作者: {{World Health Organization}}

exportBibtex(items) → string

将 CSL-JSON 物品序列化为 BibTeX 。 生产有 en-dash 页面范围的清洁输出( E)--)和适当名称格式.

convertLatex(str) → string

将 LaTeX 口音序列和特殊命令转换为 Unicode 字符 。 在全剖析器外处理单个 BibTeX 字段值时有用 .

版本与发布记录

@citestyle/bibtex 共发布 4 个版本,首次发布于 2026/03/13;过去 12 个月发布了 4 个版本。

版本发布日期距今
1.1.0latest2026/05/305 个月前
1.0.12026/04/276 个月前
1.0.02026/03/137 个月前
0.0.22026/03/137 个月前

关于 @citestyle/bibtex 的常见问题

@citestyle/bibtex 是什么?

BibTeX QQ CSL- JSON 解析器和序列器

如何安装 @citestyle/bibtex?

在项目目录运行 npm install @citestyle/bibtex,或使用 pnpm add / yarn add / bun add。

@citestyle/bibtex 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@citestyle/bibtex 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@citestyle/bibtex 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@citestyle/bibtex 可以商用吗?

@citestyle/bibtex 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@citestyle/bibtex 的下载量有多少?

根据 npm 官方下载统计,@citestyle/bibtex 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,023 次,日均约 67 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@citestyle/bibtex 还在维护吗?

最新版本 1.1.0 发布于 2026/05/30(5 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/03/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。