citation-js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.

MIT 111 个版本
安装
npm install citation-js
yarn add citation-js
pnpm add citation-js
bun add citation-js
README

NPM version NPM total downloads Build Status JavaScript Style Guide

Please use citation-js/citation-js if possible.

citation-js/citation-js replaces larsgw/citation.js
This repository contains the npm package @citation-js/core and several other components. This repository contains the npm package citation-js that wraps the aforementioned components for backwards compatibility.

Install

On Node.js, install the package (citation-js) like this:

npm install citation-js

To install the CLI as a global command, do this:

npm install --global citation-js

Browser releases are available here. These define require and add citation-js as a module.

<script src="path/to/citation.js" type="text/javascript"></script>
<script>
  const Cite = require('citation-js')
</script>

Getting Started

You can read a guide on how to get started, together with some tutorials and examples, here.

CLI

More info

Run the CLI like this:

citation-js  [options]

Options:

  -h, --help                      output usage information
  -V, --version                   output the version number

  -i, --input <path>              Input file
  -u, --url <url>                 Input url
  -t, --text <string>             Input text

  -o, --output <path>             Output file (omit file extension)

  -R, --output-non-real           Do not output the file in its mime type, but as a string
  -f, --output-type <option>      Output structure type: string, html, json
  -s, --output-style <option>     Output scheme. A combination of --output-format json and --output-style citation-* is considered invalid. Options: csl (Citation Style Lanugage JSON), bibtex, citation-* (where * is any formatting style)
  -l, --output-language <option>  Output language. [RFC 5646](https://tools.ietf.org/html/rfc5646) codes

Cite

More info

To use the Cite constructor, require() the module like this:

const Cite = require('citation-js')

For example, to get the bibliographical data of the Wikidata item wd:Q21972834, and then format it in HTML, English and APA:

let example = new Cite('Q21972834')

let output = example.format('bibliography', {
  format: 'html',
  template: 'apa',
  lang: 'en-US'
})

console.log(output)

To test this code, go to RunKit.

Async

Use the async API (recommended for Wikidata, URL, and DOI input) like this:

let example = await Cite.async('Q21972834')

let output = example.format('bibliography', {
  format: 'html',
  template: 'apa',
  lang: 'en-US'
})

console.log(output)

Cite.async() also supports options as the second argument, and a callback function as last argument.

版本列表
0.8.2 2026-07-13
0.8.1 2026-07-06
0.8.0 2026-07-06
0.7.22 2025-12-31
0.7.21 2025-10-20
0.7.20 2025-07-05
0.7.19 2025-05-12
0.7.18 2025-01-28
0.7.17 2025-01-28
0.7.16 2024-09-23
0.7.15 2024-08-11
0.7.14 2024-06-12
0.7.13 2024-06-06
0.7.12 2024-05-07
0.7.11 2024-04-17
0.7.10 2024-03-27
0.7.9 2024-03-05
0.7.8 2024-01-22
0.7.7 2024-01-22
0.7.6 2024-01-17
0.7.5 2024-01-06
0.7.4 2023-11-01
0.7.3 2023-11-01
0.7.2 2023-11-01
0.7.1 2023-09-23
0.7.0 2023-09-23
0.6.9 2023-09-20
0.6.8 2023-05-10
0.6.7 2023-02-14
0.6.6 2023-01-31
0.6.5 2022-12-31
0.6.4 2022-07-19
0.6.3 2022-06-23
0.6.2 2022-06-02
0.6.1 2022-06-02
0.6.0 2022-05-30
0.5.7 2022-04-17
0.5.6 2022-02-12
0.5.5 2021-12-31
0.5.4 2021-12-11
0.5.3 2021-11-24
0.5.2 2021-11-24
0.5.1 2021-05-11
0.5.0-alpha.10 2021-01-28
0.5.0-alpha.9 2020-10-20
0.5.0-alpha.8 2020-10-20
0.5.0-alpha.7 2020-08-29
0.5.0-alpha.6 2020-07-05
0.5.0-alpha.5 2020-03-08
0.5.0-alpha.4 2019-10-15
0.5.0-alpha.3 2019-10-08
0.5.0-alpha.2 2019-09-10
0.5.0-alpha.0 2019-09-07
0.5.0 2021-04-01
0.4.10 2019-08-27
0.4.9 2019-08-27
0.4.8 2019-07-06
0.4.7 2019-06-29
0.4.6 2019-06-29
0.4.5 2019-06-13
0.4.4 2019-06-13
0.4.2 2019-06-13
0.4.1 2019-06-13
0.4.0-12 2019-03-17
0.4.0-11 2018-12-27
0.4.0-10 2018-11-02
0.4.0-9 2018-07-19
0.4.0-8 2018-07-14
0.4.0-7 2018-07-11
0.4.0-6 2018-06-30
0.4.0-5 2018-06-03
0.4.0-4 2018-05-18
0.4.0-3 2018-05-11
0.4.0-1 2017-12-31
0.4.0-0 2017-12-22
0.4.0 2019-04-13
0.3.4 2017-09-12
0.3.3 2017-09-12
0.3.2 2017-09-10
0.3.1 2017-09-03
0.3.0-14 2017-08-24
0.3.0-13 2017-08-22
0.3.0-12 2017-08-01
0.3.0-11 2017-07-28
0.3.0-10 2017-07-22
0.3.0-9 2017-07-06
0.3.0-8 2017-06-03
0.3.0-7 2017-05-22
0.3.0-6 2017-05-15
0.3.0-5 2017-05-08
0.3.0-4 2017-04-30
0.3.0-3 2017-04-08
0.3.0-2 2017-03-14
0.3.0-1 2017-03-14
0.3.0-0 2017-03-13
0.3.0 2017-08-25
0.2.15 2017-01-31
0.2.14 2017-01-03
0.2.13 2016-12-31
0.2.12 2016-12-31
0.2.11 2016-12-28
0.2.10 2016-11-20
0.2.8 2016-10-27
0.2.7 2016-10-27
0.2.6 2016-10-27
0.2.5 2016-10-27
0.2.4 2016-10-27
0.2.3 2016-10-27
0.2.2 2016-10-27
0.2.1 2016-10-27
0.2.0 2016-10-27