Minor: Improvement to bibtex-to-cff (#120)
This commit is contained in:
+6
-3
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
// create CITATION.cff file for Github from a bibtex file
|
// 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
|
// 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/
|
// script part of https://github.com/monperrus/bibtexbrowser/
|
||||||
//
|
//
|
||||||
// Usage
|
// Usage
|
||||||
// $ php bibtexbrowser-cff.php test_cli.bib --id classical
|
// $ php bibtex-to-cff.php test_cli.bib --id classical
|
||||||
// -> this creates a file CITATION.cff for @xx{classical,
|
// -> this creates a file CITATION.cff for @xx{classical,
|
||||||
|
|
||||||
$_GET['library']=1;
|
$_GET['library']=1;
|
||||||
@@ -14,13 +14,16 @@ function bibtexbrowser_cff($arguments) {
|
|||||||
$db = new BibDataBase();
|
$db = new BibDataBase();
|
||||||
$db->load($arguments[1]);
|
$db->load($arguments[1]);
|
||||||
$current_entry=NULL;
|
$current_entry=NULL;
|
||||||
$current_field=NULL;
|
|
||||||
for ($i=2;$i<count($arguments); $i++) {
|
for ($i=2;$i<count($arguments); $i++) {
|
||||||
$arg=$arguments[$i];
|
$arg=$arguments[$i];
|
||||||
if ($arg=='--id') {
|
if ($arg=='--id') {
|
||||||
$current_entry = $db->getEntryByKey($arguments[$i+1]);
|
$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();
|
echo $current_entry->toCFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user