Git Product home page Git Product logo

doi2bib's Introduction

DOI2BIB

Status GitHub Issues GitHub Pull Requests NPM Downloads License


A node.js package to retrieve citation information of any given DOI, document or string text, and update it to a specified BibText (.bib) file.

๐Ÿ“ Table of Contents

๐Ÿง About

This package parse Markdown files or text strings searching for DOI references with the format: @DOI:---.---/-----------. It keeps a *.bib file (library.bib per default) updated by adding the necessary references and information obtained from http://dx.doi.org/.

This package is used as part of the pandoc-doi2bib filter and pdf2doi utilities.

๐Ÿ Getting Started

These instructions will get you the doi2bib package to use on your node projects.

Installing

For using as Node.js package use:

npm install --save doi2bib

And for development, clone the repository as:

git clone https://github.com/aeroreyna/doi2bib
cd doi2bib
npm install

๐ŸŽˆ Usage

This package exposes the following functions:

  • updateFromText(text): Looks for DOI references and updates the .bib file.
  • updateFromFile(file): Read the file and uses the function updateFromText.
  • watchFile(file): Read the file and keeps and eye on it looking for new references.
  • getCitation(DOI): Obtain and return the citation of the DOI document and added to the library if necessary.
  • setLibraryFile(file): Change the bibliography .bib file to work on.

An example could be:

const doi2bib = require("./index.js");

doi2bib.getCitation('10.1007/s10462-018-09676-2').then((r)=>{
  console.log(r)
});

Which keeps an eye on the specified file in case of new DOI references are given.

Using Gulp

It also can be used with Gulp as a task to act when .md files in a directory changes using the follow gulp file.

const { src, dest, watch, task } = require('gulp');
const through = require('through2');
const doi2bib = require('doi2bib');


let updateBib = function() {
  return src(['**/*.md','!./node_modules/**/*.md'])
    .pipe(through.obj(function (chunk, enc, cb) {
      console.log('File:', chunk.path);
      doi2bib.updateFromText(chunk.contents.toString());
      cb(null, chunk);
    }));
}

task('default', updateBib);

let watcher = watch(['**/*.md','!./node_modules/**/*.md']);

watcher.on('change', function(path, stats) {
  console.log(`File ${path} was changed`);
  doi2bib.updateBibFromFile(path);
});

watcher.on('add', function(path, stats) {
  console.log(`File ${path} was added`);
  doi2bib.updateBibFromFile(path);
});

โ›๏ธ Built Using

โœ๏ธ Authors

See also the list of contributors who participated in this project.

To do:

  • remove nets dependency
  • make sure all functions return a Promise
  • catch errors in promises

doi2bib's People

Contributors

aeroreyna avatar

Stargazers

Anthony Ebert "Ace" avatar

Watchers

James Cloos avatar  avatar

Forkers

tianyishi2001

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.