-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
bibtex-to-cff.php
executable file
·32 lines (28 loc) · 993 Bytes
/
bibtex-to-cff.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
// create CITATION.cff file for GitHub from a bibtex file
// reference documentation: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#about-citation-files
// script part of https://github.com/monperrus/bibtexbrowser/
//
// Usage
// $ php bibtex-to-cff.php test_cli.bib --id classical
// -> this creates a file CITATION.cff for @xx{classical,
$_GET['library']=1;
require('bibtexbrowser.php');
function bibtexbrowser_cff($arguments) {
$db = new BibDataBase();
$db->load($arguments[1]);
$current_entry=NULL;
for ($i=2;$i<count($arguments); $i++) {
$arg=$arguments[$i];
if ($arg=='--id') {
$current_entry = $db->getEntryByKey($arguments[$i+1]);
}
}
if (is_null($current_entry)) {
echo "Did not find entry specified in the --id argument.";
return;
}
echo $current_entry->toCFF();
}
bibtexbrowser_cff($argv);
?>