Get started with citation-js CDN

MIT licensed

Citation-JS is a lightweight library for generating and manipulating bibliographic citations.

Tags:
  • citation
  • bibtex
  • wikidata
  • contentmine
  • quickscrape
  • csl
  • citeproc

Stable version

Copied!

How to start using citation-js CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with citation-js CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
  <script src="https://cdn.cdnhub.io/citation-js/0.7.9/citation.min.js"></script>
  <script>
    // Define a BibTeX string
    const bibtexString = `
      @article{doi:10.1038/s41591-021-01445-3,
        title = {The impact of climate change on global food security},
        author = {Smith, J. Doe and Johnson, A. Doe},
        journal = {Nature Climate Change},
        volume = {12},
        number = {8},
        pages = {1234--1242},
        year = {2022},
        doi = {10.1038/s41591-021-01445-3}
      }
    `;

    // Parse the BibTeX string
    const citationParser = new window.CitationParser();
    const citation = citationParser.parse(bibtexString);

    // Print the parsed citation
    console.log(citation.toCitation());

    // Fetch bibliography data from a remote API using Axios
    axios.get('https://api.example.com/bibtex')
      .then(response => {
        // Parse the BibTeX data and print the citations
        const bibtexData = response.data;
        const parser = new window.CitationParser();
        const citations = parser.parse(bibtexData);
        citations.forEach(citation => console.log(citation.toCitation()));
      })
      .catch(error => console.error(error));
  </script>
</head>
<body>
</body>
</html>
Copied!
Copied!

All versions