@dwhieb/ling-ref
v1.1.0
Published
A JavaScript library that converts a Mendeley document to an HTML citation following the Unified Stylesheet for Linguistics
Downloads
4
Maintainers
Readme
ling-ref
ling-ref is a small JavaScript library (browser / Node) for converting Mendeley documents to a citation in HTML following the Unified Stylesheet for Linguistics.
This library is useful for any linguist who uses Mendeley as their bibliography management software and would like to create a presentation format of their bibliography in Markdown or HTML.
Found a bug? Open an issue on GitHub.
Created and maintained by Daniel W. Hieber.
Getting Mendeley Data
Before using this library, you will need to get your Mendeley references in JSON format. Mendeley is a software and service for managing bibliographic sources. Once you have added references to your database, you can retrieve those references in JSON format using the Mendeley API.
The easiest way to get your Mendeley references into JSON format is by using Mendeley's API explorer. Simply log in with your Mendeley credentials, and you can make requests to the Mendeley API. Most likely you will want to make a GET /documents
request. You can then copy-paste the JSON data from the response.
You can also access the Mendeley API programmatically. See the Mendeley developer documentation for more information.
Important: Make sure that the view
parameter is set to all
when requesting documents, whether using the API programmatically or using the API explorer.
Usage
Start by getting your Mendeley references in JSON format (see above).
Install the library:
npm install -D ling-ref
yarn add --dev ling-ref
ling-ref exports a single function which converts a Mendeley reference to a citation in HTML:
// import the ling-ref library
import convertReference from 'ling-ref';
// get your Mendeley documents in JSON format
const references = getMendeleyReferences();
// convert each reference to an HTML citation
const citations = references.map(convertReference);
// add the citations to your HTML
const referenceList = document.querySelector(`ul#reference-list`);
citations.forEach(citation => {
const p = document.createElement(`p`);
p.textContent = citation;
referenceList.appendChild(p);
});