Lightweight CSL Engine. WIP.
NPM install:
npm i csl-js
Browser not supported yet
Use: (API usage below)
const { Formatter, locales, styles } = require('csl-js')const style = await (await fetch('https://cdn.jsdelivr.net/gh/citation-style-language/styles@master/apa.csl')).text()
styles.set('apa', style)
const locale = await (await fetch('https://cdn.jsdelivr.net/gh/citation-style-language/locales@master/locales-en-US.xml')).text()
locales.set('en-US', locale)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)cs:text,cs:number,cs:label,cs:group,cs:layout,cs:macroscs:choose(with most conditions)- basic
cs:names - basic et-al support
- basic
cs:date - sorting
- global and semi-local options (but not necessarily implementations)
- locales
- formatting, affixes, delimiter, strip-periods (mostly, anyway)
cs:bibliography,cs:citation- test suite (the official one)
- disambiguation
- date ranges, BC
- better number handling
- reference manager
- term genders
- jsdoc and documentation & examples