0.0.2 • Published 5 years ago

csl-js v0.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

CSL-JS

Lightweight CSL Engine. WIP.

NPM version license

JavaScript Style Guide


Table of Contents

Get Started

NPM install:

 npm i csl-js

Browser not supported yet

Use: (API usage below)

const { Formatter, locales, styles } = require('csl-js')

API

Registering/parsing locales & styles

const style = await (await fetch('https://cdn.jsdelivr.net/gh/citation-style-language/styles@master/apa.csl')).text()
styles.set('apa', style)

const style = await (await fetch('https://cdn.jsdelivr.net/gh/citation-style-language/locales@master/locales-en-US.xml')).text()
locales.set('en-US', parsed)

Formatter

Create:

const formatter = new Formatter({
  style: '...',
  lang: '...',
  format: '...'
})

Format: (data in CSL-JSON format)

formatter.formatBibliography(data)
// (1957). Correlation of the Base Strengths of Amines 1 () []. Journal of the American Chemical Society, 79(20), 5441-5444. https://doi.org/10.1021/ja01577a030

formatter.formatCitation(data)
// (1957)

Features

  • cs:text, cs:number, cs:label, cs:choose, cs:group, cs:date, cs:layout, cs:macros
  • locales
  • formatting, affixes, delimiter, strip-periods (mostly, anyway)
  • bibliography

Missing spec features

  • names
  • disambiguation
  • date ranges, BC
  • better number handling
  • cs:citation
  • sorting
  • reference manager
  • term genders
  • jsdoc and documentation & examples
  • test suite