Giter Site home page Giter Site logo

bibconverter's Introduction

Converter

Build Status

A small library to convert the input data for different literature standards like BibTeX, CSL etc. into each other. At the moment are supported BibTeX, CSL and RIS.

Installation

Add to the composer.json the require key and run composer install.

    "require" : {
        "geissler/converter": "dev-master"
    }

Other

Make sure you are using a PSR-2 compatible autoloader.

Usage

To convert form one standard to an other:

    // include the composer autoloader
    require __DIR__ . '/vendor/autoload.php';

    use Geissler\Converter\Converter;
    use Geissler\Converter\Standard\RIS\RIS;
    use Geissler\Converter\Standard\BibTeX\BibTeX;
    use Geissler\Converter\Standard\CSL\CSL;

    $converter  =   new Converter();

    // your input RIS data
    $data = 'TY  - JOUR
             TI  - Die Grundlage der allgemeinen Relativitätstheorie
             AU  - Einstein, Albert
             PY  - 1916
             SP  - 769
             EP  - 822
             JO  - Annalen der Physik
             VL  - 49
             ER  - ';

    // convert to bibTeX
    $bibTeX =   $converter->convert(new RIS($data), new BibTeX());

    /**
     * $bibTeX has know the following value:
     *
     * @article{article,
     *      author = {Einstein, Albert},
     *      year = {1916},
     *      pages = {769-822},
     *      title = {Die Grundlage der allgemeinen Relativitätstheorie},
     *      volume = {49}
     * }
     */

     // or convert bibTeX to csl
     $csl   =   $converter->convert(new BibTeX($bibTeX), new CSL());

     /**
      * $csl has know the following value (a UTF-8 encoded json string):
      *
      * [
      *     {
      *         "type":"article",
      *         "author":[{
      *             "family":"Einstein",
      *             "given":"Albert"
      *         }],
      *         "issued":[{
      *             "year":"1916"
      *         }],
      *         "page":"769-822",
      *         "page-first":"769",
      *         "citation-label":"article",
      *         "title":"Die Grundlage der allgemeinen Relativit\u00e4tstheorie"
      *     }
      * ]
      */

Adding a standard

To implement a new standard is quite simple:

  1. Create a copy of the folder src/Geissler/Converter/Standard/Template
  2. Change the name to the new standard.
  3. Rename also the Template.php file to the name of the standard
  4. Replace every occurence of Template in the files Creator.php, Parser.php and Template.php with the name of the new standard.
  5. Implement the methods create and retrieve in Creator.php
  6. Implement the methods parse and retrieve in Parser.php
  7. Don't forget to write your PHPUnit tests and follow the PSR-2 coding standard

bibconverter's People

Contributors

bluem avatar burki avatar daviian avatar geissler avatar

Watchers

 avatar  avatar

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.