Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/larsgw/csl-js
Lightweight CSL Engine
https://github.com/larsgw/csl-js
Last synced: 11 days ago
JSON representation
Lightweight CSL Engine
- Host: GitHub
- URL: https://github.com/larsgw/csl-js
- Owner: larsgw
- License: mit
- Created: 2017-11-26T16:04:08.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2023-01-07T21:43:12.000Z (almost 2 years ago)
- Last Synced: 2023-04-09T22:13:03.024Z (over 1 year ago)
- Language: JavaScript
- Size: 577 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CSL-JS
Lightweight CSL Engine. WIP.
[![NPM version](https://img.shields.io/npm/v/csl-js.svg)](https://www.npmjs.org/csl-js)
[![license](https://img.shields.io/github/license/larsgw/csl-js.svg)](https://github.com/larsgw/csl-js/blob/master/LICENSE.md)[![JavaScript Style Guide](https://cdn.jsdelivr.net/gh/standard/standard@master/badge.svg)](https://github.com/standard/standard)
---
##### Table of Contents
- [Get Started](#get-started)
- [API](#api)
- [Registering/parsing locales & styles](#registering--parsing-locales---styles)
- [Formatter](#formatter)
- [Features](#features)
- [TODOs](#todos)## Get Started
NPM install:
npm i csl-js
> Browser not supported yet
Use: (API usage below)
```js
const { Formatter, locales, styles } = require('csl-js')
```## API
### Registering/parsing locales & styles
```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)
```### `Formatter`
Create:
```js
const formatter = new Formatter({
style: '...',
lang: '...',
format: '...'
})
```Format: (data in CSL-JSON format)
```js
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/ja01577a030formatter.formatCitation(data)
// (1957)
```## Features
- `cs:text`, `cs:number`, `cs:label`, `cs:group`, `cs:layout`, `cs:macros`
- `cs: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)## Missing spec features
- disambiguation
- date ranges, BC
- better number handling
- reference manager
- term genders
- jsdoc and documentation & examples