diff --git a/README.md b/README.md
index 4ae355c..7648661 100644
--- a/README.md
+++ b/README.md
@@ -1,49 +1,53 @@
[](https://zenodo.org/badge/latestdoi/67431697)
-# doi2bib and friends
-
-This repository provides scripts for converting from either [Digital Object Identifier (DOI)](https://www.doi.org) or [Uniform Resource Locator (URL)](https://en.wikipedia.org/wiki/URL) to [BibTeX](http://www.bibtex.org), or from DOI to plain text.
-
-## doi2bib
+TODO: support storing to the clipboard automatically.
+TODO: add the surname of the first author automatically if not given (if only the year is shown as id when retrieved)
-Convert [Digital Object Identifier (DOI)](https://www.doi.org) to
-[BibTeX](http://www.bibtex.org) using
-[crosscite.org](https://citation.crosscite.org/).
-DOIs are received and the corresponding BibTeX entries are output.
+# Bibliography in your command-line
-Inspired by and
-.
+This repository provides scripts for converting from either [Digital Object Identifier (DOI)](https://www.doi.org) or [Uniform Resource Locator (URL)](https://en.wikipedia.org/wiki/URL) to [BibTeX](http://www.bibtex.org), or from DOI to plain text.
+
+## `doi2bib`
-**October 16, 2017**: seems not to be working
-any more.
+Convert [Digital Object Identifier (DOI)](https://www.doi.org) to [BibTeX](http://www.bibtex.org) using [crosscite.org](https://citation.crosscite.org/).
+DOIs are received and the corresponding BibTeX entries are output.
+(Inspired by and .)
-## doi2text
+## `doi2text`
-Convert [Digital Object Identifier (DOI)](https://www.doi.org) to plain text
-using [crosscite.org](https://citation.crosscite.org/). DOIs are received and
-the corresponding text entries are output. In theory, all the styles
-available at can be used.
+Convert [Digital Object Identifier (DOI)](https://www.doi.org) to plain text using [crosscite.org](https://citation.crosscite.org/).
+DOIs are received and the corresponding text entries are output. In theory, all the styles available at can be used.
-## url2bib
+## `url2bib`
-Convert [Uniform Resource Locator (URL)](https://en.wikipedia.org/wiki/URL) to
-[BibTeX](http://www.bibtex.org) using pure
-[Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)).
+Convert [Uniform Resource Locator (URL)](https://en.wikipedia.org/wiki/URL) to [BibTeX](http://www.bibtex.org) using pure [Bash]().
URLs are received and the corresponding BibTeX entries are output.
+(This is made to be used exactly as one would use `doi2bib`.)
-(This is made to be used exactly as one would use doi2bib.)
+This requires `gawk` (`sudo apt install gawk`).
+
+## Dependencies
+
+`doi2bib` requires [curl](https://curl.haxx.se/):
+
+ $ sudo apt install curl
+
+You will also need `make` to install:
+
+ $ sudo apt install make
## Installation
After downloading the tarball and using `cd` to go where the files are, simply do a `sudo make install` and everything will be installed.
+By default, it will install in `/usr/local/bin/`.
## Usage
- $ doi2bib 10.1021/acs.jpcc.8b06244 10.1021/acscatal.9b00210
+ $ doi2bib 10.1021/acs.jpcc.8b06244 10.1021/acscatal.9b00210
@article{Schneider_2018,
title={How Do Secondary Phosphine Oxides Interact with Silver Nanoclusters? Insights from Computation},
volume={122},
@@ -92,3 +96,7 @@ After downloading the tarball and using `cd` to go where the files are, simply d
howpublished = {\url{https://github.com/schneiderfelipe/doi2bib}},
note = {Accessed: 2020-01-27}
}
+
+## Citing doi2bib
+
+If you use doi2bib in your research, please cite it.
diff --git a/src/bibmagic.py b/src/bibmagic.py
new file mode 100644
index 0000000..7935507
--- /dev/null
+++ b/src/bibmagic.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+import sys
+import bibtexparser as btp
+from bibtexparser.bparser import BibTexParser
+from bibtexparser.customization import homogenize_latex_encoding
+
+with open(sys.argv[1]) as bib_file:
+ parser = BibTexParser()
+ # parser.customization = homogenize_latex_encoding
+ bib_db = btp.load(bib_file, parser=parser)
+
+if len(sys.argv) > 2:
+ with open(sys.argv[2], 'w') as bib_file:
+ btp.dump(bib_db, bib_file)
+else:
+ print(btp.dumps(bib_db))
diff --git a/src/doi2bib b/src/doi2bib
index 5e04bf2..9371b85 100755
--- a/src/doi2bib
+++ b/src/doi2bib
@@ -71,9 +71,12 @@ for doi in "$@"; do
# we do some encoding as needed.
doi=${doi//+/%2B}
http_headers="Accept: text/bibliography; style=bibtex"
+
+ echo "$http_headers"
+ echo
# we retrieve the data from https://doi.org/
- curl -s -LH "$http_headers" "https://doi.org/${doi}" | \
+ curl -LH "$http_headers" "https://doi.org/${doi}" | \
sed -e $'s/^ *//' \
-e $'s/}, /},\\\n /g' \
-e $'s/, /,\\\n /1' \
diff --git a/src/doi2text b/src/doi2text
index a7624ab..06a030e 100755
--- a/src/doi2text
+++ b/src/doi2text
@@ -34,7 +34,7 @@
#? -v show version
#? -s set ciation style from the ones given in
#? (this is
-#? "chicago-author-date" by default, see examples below)
+#? "american-chemical-society" by default, see examples below)
#? -S list all available citation styles and quit
#? -l set locale from the ones given in
#? , e.g. "pt-BR"
@@ -55,8 +55,9 @@
#? doi2text and doi2bib
#? are licensed under the MIT License.
+style="american-chemical-society"
+
locale=$(locale | grep LANGUAGE | cut -d= -f2 | cut -d: -f1 | tr '_' '-')
-style="chicago-author-date"
if [ ! $locale ]; then
locale="en-US"
fi
@@ -75,7 +76,7 @@ while getopts ":hvs:Sl:L" opt "$@"; do
style="${OPTARG}"
;;
S) # list all styles
- curl -s -X GET \
+ curl -X GET \
https://api.github.com/repos/citation-style-language/styles/contents/\?ref\=master | \
sed -e '/"name":.*\.csl"/{s/\s*"name": "//;s/\.csl",\s*//;p};d'
exit 0
@@ -84,7 +85,7 @@ while getopts ":hvs:Sl:L" opt "$@"; do
locale="${OPTARG}"
;;
L) # list all styles
- curl -s -X GET \
+ curl -X GET \
https://api.github.com/repos/citation-style-language/locales/contents/\?ref\=master | \
sed -e '/"name":.*\.xml"/{s/\s*"name": "//;s/\.xml",\s*//;s/locales-//;p};d'
exit 0
@@ -108,7 +109,10 @@ for doi in "$@"; do
# we do some encoding as needed.
doi=${doi//+/%2B}
http_headers="Accept: text/x-bibliography; style=${style}; locale=${locale}"
+
+ echo "$http_headers"
+ echo
# we retrieve the data from https://doi.org/
- curl -s -LH "$http_headers" "https://doi.org/${doi}"
+ curl -LH "$http_headers" "https://doi.org/${doi}"
done