# @citation-js/plugin-csl Plugin for CSL output for Citation.js. Output generation is done with [`citeproc-js`](https://github.com/Juris-M/citeproc-js). [![NPM version](https://img.shields.io/npm/v/@citation-js/plugin-csl.svg)](https://npmjs.org/package/@citation-js/plugin-csl) [![NPM total downloads](https://img.shields.io/npm/dt/@citation-js/plugin-csl.svg)](https://npmcharts.com/compare/@citation-js%2Fplugin-csl?minimal=true) ![License](https://img.shields.io/npm/l/@citation-js/plugin-csl.svg) ![Dependency status](https://img.shields.io/librariesio/release/npm/@citation-js/plugin-csl) --- ## Install npm install @citation-js/plugin-csl ## Usage Register by importing the package: ```js require('@citation-js/plugin-csl') ``` ## Formats Formats and other features added by this plugin. General output options: * `template`: the style template to use. Currently, the following are built-in: * `apa` (default) * `vancouver` * `harvard1` * `lang`: the locale to use. Currently, the following are built-in: * `en-US` (default) * `es-ES` * `de-DE` * `fr-FR` * `nl-NL` * `format`: output (markup) format. Note: this doesn't support the output format dictionaries * `entry` (`String`, `Array[String]`): entry ID or list of entry IDs to identify the items to cite ### Bibliography This plugin adds the output format `bibliography`, and accepts the following specific options: * `prepend` (`String`, `Function`): prepend static or dynamic text to each entry * `append` (`String`, `Function`): append static or dynamic text to each entry * `nosort` (`Boolean`, default: `false`): do not sort according to the style-defined rules * `asEntryArray` (`Boolean`, default: `false`): return an array of entries consisting of an id and the output for that individual entry Here's an example for `prepend` and `append`: ```js let cite = new Cite({ id: 'a', title: 'Item A' }) cite.format('bibliography', { append: ' [foobar]' }) // 'Item A. (n.d.). [foobar]\n' cite.format('bibliography', { prepend (entry) { return `${entry.id}: ` } }) // 'a: Item A. (n.d.).\n' ``` And here's another example, possibly more realistic: ```js let cite = new Cite('Q30000000') let date = (new Date()).toLocaleDateString() cite.format('bibliography', { format: 'html', template: 'apa', prepend (entry) { return `[${entry.id}]: ` }, append: ` [Retrieved on ${date}]` }) // `