researchgate / converter
A small library to convert different bibliography formats into each other. Forked from 'geissler/converter'.
Installs: 10 442
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 13
Open Issues: 1
Requires
- php: ^7.4 | ^8.0 | ^8.1 | ^8.2
- ext-json: *
- researchgate/libris: ^2.4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.1
- phpstan/phpstan: ^1.10.38
- phpunit/phpunit: ^9.3
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^5.15.0
README
Forked from geissler/converter. Thank you for your amazing contributions 🙏.
A small library to convert the input data for different literature standards like BibTeX, CSL etc. into each other.
Supported formats:
Installation
Via composer
Just require the researchgate/converter
package as below:
$ composer require researchgate/converter
Other
Make sure you are using a PSR-4 compatible autoloader.
Usage
To convert from 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:
- Create a copy of the folder src/Geissler/Converter/Standard/Template
- Change the name to the new standard.
- Rename also the Template.php file to the name of the standard
- Replace every occurence of Template in the files Creator.php, Parser.php and Template.php with the name of the new standard.
- Implement the methods create and retrieve in Creator.php
- Implement the methods parse and retrieve in Parser.php
- Don't forget to write your PHPUnit tests and follow the PSR-12 coding standard