1.0.10 • Published 4 years ago

doi2bib v1.0.10

Weekly downloads
5
License
ISC
Repository
github
Last release
4 years ago

Status GitHub Issues GitHub Pull Requests NPM Downloads License


📝 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

npm.io

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
1.0.10

4 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago