Citation Reference

Return a reference corresponding to a citation identifier.

Usage

var toReference = require( '@stdlib/_tools/bib/citation-reference' );

toReference( id, [options,] clbk )

Returns a reference corresponding to a citation identifier.

toReference( '@press1992', clbk );

function clbk( error, reference ) {
    if ( error ) {
        throw error;
    }
    console.log( reference );
}

The function accepts the following options:

To use a specific bibliographic database, set the database option.

var opts = {
    'database': '/foo/bar/baz/bib.bib'
};

toReference( '@press1992', opts, clbk );

function clbk( error, reference ) {
    if ( error ) {
        throw error;
    }
    console.log( reference );
}

To use a particular Citation Style Language (CSL), set the csl option.

var opts = {
    'csl': '/foo/bar/baz/style.csl'
};

toReference( '@press1992', opts, clbk );

function clbk( error, reference ) {
    if ( error ) {
        throw error;
    }
    console.log( reference );
}

toReference.sync( id[, options] )

Synchronously return a reference corresponding to a citation identifier.

var ref = toReference.sync( '@press:1992' );
// returns '...'

The method accepts the same options as toReference() above.

Notes

Examples

var toReference = require( '@stdlib/_tools/bib/citation-reference' );

/* bib.bib
@book{press:1992,
    author = {William H. Press and Brian P. Flannery and Saul A. Teukolsky and William T. Vetterling},
    isbn = {0521431085},
    keywords = {computing, software, programming},
    publisher = {Cambridge University Press},
    title = {{Numerical Recipes in C: The Art of Scientific Computing, Second Edition}},
    year = {1992},
}
*/

var opts = {
    'database': 'bib.bib',
    'csl': 'chicago-author-date.csl'
};

toReference( '@press1992', opts, clbk );

function clbk( error, reference ) {
    if ( error ) {
        throw error;
    }
    console.log( reference );
    /* e.g., =>
        (Press et al. 1992)

        Press, William H., Brian P. Flannery, Saul A. Teukolsky, and William T. Vetterling. 1992. _Numerical Recipes in C: The Art of Scientific Computing, Second Edition_. Cambridge University Press.
    */
}

CLI

Usage

Usage: citation-reference [options] <citation_identifier>

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --database filepath   Database filepath.
         --csl filepath        Citation Style Language filepath.

Examples

$ citation-reference '@press:1992'
...