Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/larsgw/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.
https://github.com/larsgw/citation.js
bibtex citation citeproc-js csl-json wikidata
Last synced: about 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/larsgw/citation.js
- Owner: larsgw
- License: mit
- Created: 2015-10-30T16:58:24.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-06-12T19:59:18.000Z (3 months ago)
- Last Synced: 2024-07-18T00:16:40.368Z (2 months ago)
- Topics: bibtex, citation, citeproc-js, csl-json, wikidata
- Language: JavaScript
- Homepage: https://citation.js.org/
- Size: 10.2 MB
- Stars: 219
- Watchers: 7
- Forks: 30
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![NPM version](https://img.shields.io/npm/v/citation-js.svg)](https://npmjs.org/package/citation-js)
[![NPM total downloads](https://img.shields.io/npm/dt/citation-js.svg)](https://npmcharts.com/compare/citation-js?minimal=true)
[![Build Status](https://travis-ci.org/larsgw/citation.js.svg?branch=master)](https://travis-ci.org/larsgw/citation.js)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)Please use [citation-js/citation-js](https://github.com/citation-js/citation-js) if possible.
| [citation-js/citation-js](https://github.com/citation-js/citation-js) | replaces | [larsgw/citation.js](https://github.com/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](#install)
- [Getting Started](#getting-started)
- [CLI](#cli)
- [`Cite`](#cite)
* [Async](#async)
- [Acknowledgements](#acknowledgements)# Install
On Node.js, install the package ([citation-js](https://npmjs.org/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](https://github.com/larsgw/citation.js/tree/archive). These define `require` and add `citation-js` as a module.
```html
const Cite = require('citation-js')
```
# Getting Started
You can read a guide on how to get started, together with some tutorials and examples, [here](https://citation.js.org/api/tutorial-getting_started.html).
# CLI
> [More info](https://citation.js.org/api/tutorial-cli.html)
Run the CLI like this:
citation-js [options]
Options:
-h, --help output usage information
-V, --version output the version number-i, --input Input file
-u, --url Input url
-t, --text Input text-o, --output 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 Output structure type: string, html, json
-s, --output-style 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 Output language. [RFC 5646](https://tools.ietf.org/html/rfc5646) codes# `Cite`
> [More info](https://citation.js.org/api/tutorial-cite_.html)
To use the [`Cite`](#cite) constructor, `require()` the module like this:
```js
const Cite = require('citation-js')
```For example, to get the bibliographical data of the Wikidata item [`wd:Q21972834`](https://wikidata.org/wiki/Q21972834), and then format it in HTML, English and APA:
```js
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](https://runkit.com/larsgw/591b5651bd9b40001113931c).
## Async
Use the async API (recommended for Wikidata, URL, and DOI input) like this:
```js
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.