@citation-js/cli

中文文档
0.9.0发布于 2026/09/18MITCommonJS近 30 天下载 2.6万

CLI for Citation.js

原始使用文档
文档目录5 节
  1. Install
  2. Usage
  3. Input
  4. Output
  5. Output Format

@citation-js/cli

CLI for Citation.js.

NPM version NPM total downloads License Dependency status

Install

npm install --global @citation-js/cli

Usage

Usage: citation-js [options]

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

  -i, --input <path>                 Input file. If all input options are omitted, it uses stdin
  -t, --text <string>                Input text. If all input options are omitted, it uses stdin
  -o, --output <path>                Output file (omit file extension). If this option is omitted, the output is written to stdout
  --pipe                             Pipe and transform from stdin to stdout

  -R, --output-non-real              Output as a text file
  -f, --output-type <option>         Output structure type: string, html, json (default: "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) (default: "csl")
  -l, --output-language <option>     Output language. [RFC 5646](https://tools.ietf.org/html/rfc5646) codes (default: "en-US")

  --log-level <level>                Log level: silent, error, warn, info, debug, http (default: "warn")

  --plugins <names>                  Plugin names (@citation-js/plugin-NAME); bibjson, bibtex, csl, doi, ris & wikidata are preloaded (default: [])
  --plugin-config <config>           @plugin.property.path=value;... (default: [])
  --formatter-options <config>       property.path=value;... (default: [])

  --no-input-generate-graph          Do not include the parsing graph in CSL output
  --input-force-type <type>          Force parsing as a certain type
  --input-max-chain-length <number>  Set the maximal number of parsing iterations
  --no-input-strict                  Do not use the strict parsing mode
  --input-target <type>              Stop parsing when a certain type is reached

Input

Input can be read from stdin, passed as a file with -i, --input <path> or, for simple IDs, as plain text with -t, --text.

$ echo "Q30000000" > input.txt

$ cat input.txt | citation-js
[{"title": "The Synergistic Activity ...", ...}]

$ citation-js --input input.txt
[{"title": "The Synergistic Activity ...", ...}]

$ citation-js --text Q30000000
[{"title": "The Synergistic Activity ...", ...}]

Output

The CLI outputs to stdout by default, but can write to a file with the -o, --output option.

$ citation-js --text Q30000000
[{"title": "The Synergistic Activity ...", ...}]

$ citation-js -t Q30000000 -o output
$ more output.json
[{"title": "The Synergistic Activity ...", ...}]

Note: the file extension is determined automatically, and should therefore be omitted in the -o option. To force a file extension, simply omit -o and redirect stdout to the preferred file.

Output Format

To format the output, use the -R, -s, -f and -l options. These options map to the old output options.

CLI optionDefault valueOther values
-R, --output-non-realomitted (real)present (string, plain text)
-f, --output-typejsonjson, string
-s, --output-stylecslcitation-*, bibtex, bibtxt, data
-l, --output-languageen-USes-ES, fr-FR, du-DU, nl-NL

For example, to format doi:10.5281/zenodo.1005176 in French in the APA format:

$ citation-js -t 10.5281/zenodo.1005176 -f string -s citation-apa -l fr-FR

Willighagen, L., & Willighagen, E. (2017,  octobre 9). Larsgw/Citation.Js V0.3.3. Zenodo. https://doi.org/10.5281/zenodo.1005176

版本与发布记录

@citation-js/cli 共发布 73 个版本,首次发布于 2018/12/07;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.9.0latest2026/09/181 个月前
0.8.22026/07/133 个月前
0.8.12026/07/064 个月前
0.8.02026/07/064 个月前
0.7.222026/01/0110 个月前
0.7.212025/10/201.1 年前

关于 @citation-js/cli 的常见问题

@citation-js/cli 是什么?

CLI for Citation.js

如何安装 @citation-js/cli?

在项目目录运行 npm install @citation-js/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 citation-js,可以用 npx citation-js 直接运行。

@citation-js/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/citation-js__cli 是否存在。

@citation-js/cli 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@citation-js/cli 需要什么版本的 Node.js?

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

@citation-js/cli 可以商用吗?

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

@citation-js/cli 的下载量有多少?

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

@citation-js/cli 还在维护吗?

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