Skip to content

Commit 739888f

Browse files
Merge branch 'release/1.0'
2 parents fe5a130 + fbe4ac4 commit 739888f

File tree

2 files changed

+60
-39
lines changed

2 files changed

+60
-39
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Convert [Digital Object Identifier (DOI)](https://www.doi.org) to
44
[BibTeX](http://www.bibtex.org) using
55
[crosscite.org](https://citation.crosscite.org/).
6-
A DOI is received and a corresponding BibTeX entry is output.
6+
DOIs are received and the corresponding BibTeX entries are output.
77

88
Inspired by <https://gist.github.com/mlund/4609288> and
99
<http://www.doi2bib.org/>.
@@ -13,7 +13,7 @@ any more.
1313

1414
## Usage
1515

16-
$ doi2bib 10.1021/la203078w
16+
$ doi2bib 10.1021/la203078w 10.1103/PhysRev.140.A1133
1717
@article{Cabaleiro_Lago_2012,
1818
title={The Effect of Nanoparticles on Amyloid Aggregation Depends on the Protein Stability and Intrinsic Aggregation Rate},
1919
volume={28},
@@ -32,6 +32,23 @@ any more.
3232
pages={1852–1857}
3333
}
3434

35+
@article{Kohn_1965,
36+
title={Self-Consistent Equations Including Exchange and Correlation Effects},
37+
volume={140},
38+
ISSN={0031-899X},
39+
url={http://dx.doi.org/10.1103/PhysRev.140.A1133},
40+
DOI={10.1103/physrev.140.a1133},
41+
number={4A},
42+
journal={Physical Review},
43+
publisher={American Physical Society (APS)},
44+
author={Kohn,
45+
W. and Sham,
46+
L. J.},
47+
year={1965},
48+
month={Nov},
49+
pages={A1133–A1138}
50+
}
51+
3552
## Installation
3653

3754
After downloading the tarball and using `cd` to go where the files are, simply do a `sudo make install` and everything will be installed.

doi2bib

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,55 +21,59 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
# SOFTWARE.
2323
#
24-
#? doi2bib 0.2
24+
#? doi2bib 1.0
2525
#?
2626
#? Convert Digital Object Identifier (DOI) to BibTeX using crosscite.org.
27-
#? A DOI is received and a corresponding BibTeX entry is output.
27+
#? DOIs are received and the corresponding BibTeX entries are output.
2828
#?
29-
#? Usage: doi2bib doi
29+
#? Usage: doi2bib doi [doi...]
3030
#?
3131
#? -h show this message
3232
#? -v show version
3333
#?
3434
#? Examples:
3535
#?
36-
#? $ doi2bib 10.1103/PhysRev.140.A1133 # write to stdout
37-
#? $ doi2bib 10.1021/la203078w
38-
#? $ doi2bib 10.1103/PhysRev.140.A1133 >> citations.bib # append to file
36+
#? $ doi2bib 10.1103/PhysRev.140.A1133 # write to stdout
37+
#? $ doi2bib 10.1103/PhysRev.140.A1133 >> citations.bib # append to file
38+
#? $ doi2bib 10.1021/la203078w 10.1103/PhysRev.140.A1133 # get many DOIs
39+
#?
40+
#? License:
41+
#?
42+
#? doi2bib <https://github.com/dudektria/doi2bib>
43+
#? is licensed under the MIT License.
3944

40-
while getopts ":hv" opt "$@"
41-
do
42-
case $opt in
43-
h) # help
44-
grep "^#?" "$0" | cut -c 4-
45-
exit 0
46-
;;
47-
v) # version
48-
grep "^#? doi2bib" "$0" | cut -c 4-
49-
exit 0
50-
;;
51-
\?)
52-
echo "Invalid option: -$OPTARG" >&2
53-
exit 1
54-
;;
55-
:)
56-
echo "Option -$OPTARG requires an argument." >&2
57-
exit 1
58-
;;
59-
esac
60-
done
45+
while getopts ":hv" opt "$@"; do
46+
case $opt in
47+
h) # help
48+
grep "^#?" "$0" | cut -c 4-
49+
exit 0
50+
;;
51+
v) # version
52+
grep "^#? doi2bib" "$0" | cut -c 4-
53+
exit 0
54+
;;
55+
\?)
56+
echo "Invalid option: -$OPTARG" >&2
57+
exit 1
58+
;;
59+
:)
60+
echo "Option -$OPTARG requires an argument." >&2
61+
exit 1
62+
;;
63+
esac
64+
done
6165

6266
# recover $@
6367
shift $((OPTIND-1))
6468

65-
# we consider everything after the command a single DOI.
66-
doi=$*
67-
68-
# we do some encoding as needed.
69-
doi=${doi//+/%2B}
69+
# we consider everything after the command a list of DOIs.
70+
for doi in "$@"; do
71+
# we do some encoding as needed.
72+
doi=${doi//+/%2B}
7073

71-
# we retrieve the data from http://dx.doi.org/
72-
curl -s -LH "Accept: text/bibliography; style=bibtex" "http://dx.doi.org/${doi}" | \
73-
sed -e 's/^ *//' \
74-
-e 's/, /,\n /g' \
75-
-e 's/}}$/}\n}\n/'
74+
# we retrieve the data from http://dx.doi.org/
75+
curl -s -LH "Accept: text/bibliography; style=bibtex" "http://dx.doi.org/${doi}" | \
76+
sed -e 's/^ *//' \
77+
-e 's/, /,\n /g' \
78+
-e 's/}}$/}\n}\n/'
79+
done

0 commit comments

Comments
 (0)